Break and continue in jquery Loop

Source: Internet
Author: User
In jquery, the operations of various controls on the cyclic page are often used. The common cyclic operations are as follows: // All div labels starting with weiguo _ id on the cyclic page $ (& quot; div [id ^ weiguo _] & quot ;). each (function (index) {// obtain the content variDValue In the div $ (this ). text ()...

In jquery, the operations of various controls on the cyclic page are often used. The commonly used cyclic operations are as follows:

// All div labels whose id starts with weiguo _ on the cyclic page

$ ("Div [id ^ = weiguo _]"). each (function (index ){

// Obtain the content in the div

Var iDValue = $ (this). text ();

// If this cycle meets the conditions, the cycle will jump out immediately.

If (iDValue = 0 ){
CheckMark = false;
BlankTextArray. push (idval );
// Break ---- identified by return false syntax
Return false;

}

}

 

Notes

Break and continue cannot be used in the each code block. To implement the break and continue functions, use the following method:
Break ---- return false;
Continue -- use return ture;

Therefore, if you want to return false or true in a jquery loop, you must note that the written statements may not be what you want.


From Wei Guo's column
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.