How to exit the current each loop through array traversal using jquery _ jquery-js tutorial

Source: Internet
Author: User
The jquery loop method is used to traverse arrays. However, when the condition is not met, how can we jump out of the current loop? The solution is as follows. If you need it, refer to the latest official website revisions, A small problem occurred while working on one of the projects. The problem is that array traversal is performed through jquery's loop method, but how to jump out of the current loop when the condition is not met.

I use $. each () for Array loop traversal, but when I enter the judgment, I don't know how to jump out of the current loop, so I found it incorrect by using the javascript method-continue. The description on the API only jumps out of the entire loop (if you need to exit the each loop, the callback function returns false, and other return values will be ignored .)

Then I checked it 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 kids shoes who are just learning jquery.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.