From the sound of this, you have something like this:
function outer(someParam) {
$.each(someParam, function(i) {
});
}
You want to return from outerwhen the inner loop reaches a certain value. You cannot do this at a time. The key point is that execution return falsefrom the callback $.eachcompletes the "loop". Then you can set the variable for conditional return if you need it:
function outer(someParam) {
var returnNow = false;
$.each(someParam, function(i) {
if (i === 5) {
returnNow = true;
return false;
}
});
if (returnNow) {
return;
}
}
source
share