i hvae applied the below code and i got the id of all the item present in the document library.i want to retrive the newest's item id.here is my code.:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices-2014.02.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
ExecuteOrDelayUntilScriptLoaded(GetListItemId, "sp.js");
});
function GetListItemId() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle('docLib1');
var query = SP.CamlQuery.createAllItemsQuery();
allItems = list.getItems(query);
context.load(allItems);
context.executeQueryAsync(Function.createDelegate(this, this.successGetListItemId));
}
function successGetListItemId() {
var TextFiled = "";
var ListEnumerator = this.allItems.getEnumerator();
while (ListEnumerator.moveNext()) {
var currentItem = ListEnumerator.get_current();
TextFiled += currentItem.get_item('ID');
}
alert(TextFiled);
}
</script>
</script>
<input type="button" onclick="GetListItemId()" value="Copy">