Home >Web Front-end >JS Tutorial >How to get out of each loop in JQuery_jquery
1. jquery each loop, to realize the break and continue functions:
break----use return false;
continue --use return ture;
2. How to get out of the current each loop in jquery
Some friends may think that you can use continue and break directly to break out of the loop in jquery, but it has no effect after using it, because there are no these two commands in jquery.
Later I checked online and got the result:
return false;——Jump out of all loops; equivalent to the break effect in JavaScript.
return true;——Jump out of the current loop and enter the next loop; equivalent to the continue effect in javascript
Example
3. Jquery each method to jump out of the loop and get the return value
return false: will stop the loop (just like using 'break' in a normal loop).
return true: Jump to the next loop (just like using 'continue' in a normal loop).