I'm running a .each
and would like the last position to have a alert
. For this I am trying to get the last position of index
:
if (index == len - 1) {
alert("Última posição");
}
Complete code:
$.getJSON("/Contrato/CriarCopiarContrato", { agrupamento: $("#listaAgrupamentos").val() },
function (result) {
$.each(result, function (index, itemData) {
if (index == len - 1) {
alert("ultima");
}
});
});