The Jquery each method jumps out of the loop and gets the return value of the example of
- 2020-03-30 00:48:49
- OfStack
Return false:
Will stop the loop (just like using 'break' in a normal loop).
Return true: Skip to the next loop (just like using 'continue' in a normal loop).
Jquery is an object chain, so $(..) .each() returns a collection of objects. Each (function(){}) : is a callback function, in the callback function cannot return the result to the callback function outside of each.
Return true: Skip to the next loop (just like using 'continue' in a normal loop).
function test(){
var success = false;
$(..).each(function () {
if (..) {
success = true;
return false;
}
});
return success ;
}
Jquery is an object chain, so $(..) .each() returns a collection of objects. Each (function(){}) : is a callback function, in the callback function cannot return the result to the callback function outside of each.