Return of each function in jquery

Source: Internet
Author: User

$ ("#dishTypeTable tbody"). Find ("tr"). EQ (0). Siblings (). each (function(index) {                var Choosenum = $ (this). Find ("TD"). EQ (1). Find ("input:checked"). Length;                Console.log (choosenum);                 if (Choosenum = = 0) {                    layer.msg ("Select at least one type of menu of participating dishes per store");                     return ;                }            });

After running the discovery does not play the role of the termination method, debug found in each function each return, just played out when the role of the secondary loop.

Baidu later found that return True (return) is equivalent to continue, jumping out of the second cycle

return false equals break, jumps out of the current loop

If you want to terminate the function, you need to throw an exception to catch and return in the catch block

Try {                $("#dishTypeTable tbody"). Find ("tr"). EQ (0). Siblings (). each (function(index) {varChoosenum = $ ( This). Find ("TD"). EQ (1). Find ("input:checked"). length;                    Console.log (Choosenum); if(Choosenum = = 0) {                        Throw"Select at least one participating menu for each store"; return;            }                }); } Catch(e) {layer.msg (e); return; }

This article is for reference only

Return of each function in jquery

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.