jquery each previous index code example
Example 1: jquery each break
$.each(array, function(key, value) {
if(value === "foo") {
return false; // breaks
}
});
// or
$(selector).each(function() {
if (condition) {
return false;
}
});
Example 2: jquery each get index
$( "li" ).each(function( index ) {
console.log( index + ": " + $( this ).text() );
});