$ ("#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