Recently, I have been busy revamping the official website, and encountered a small problem while working on one of the projects. The problem is this, array traversal is performed through jquery's loop method, but when the conditions are not met, how to break out of the current loop.
I used $.each() to loop through the array, but when entering the judgment, I didn’t know how to get out of the current loop, so I used the javascript method - continue and found that it was incorrect. The instructions on the API can only jump out of the entire loop (if you need to exit each loop, the callback function can return false, and other return values will be ignored.)
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.
PS: Share it with those who have just started learning jquery.