I have the following loop that simply checks all “green” rows in a table called items to see which one contains a hidden input element called xxx that does not match a given value:
$('table#items tr.green').each(function () {
if (myvalue != $('input#xxx', $(this)).val()){
alert('The xxx element is not the same as ' + myvalue + ' on all green rows');
return;
}
});
But there is a jQuery.ajax() request below this code and even when the alert box is displayed, the jQuery.ajax() still runs! Any idea why?
what you want is to return the function outside of the each? you cant just return inside the each, each generates a function, you return now this funktion is closed, the loop still runs, you have to do something like this