【发布时间】:2013-12-30 06:24:06
【问题描述】:
$("#savebtn").click(function() {
$('.mytable tr').each(function(){
if($('.mytable tr').length < 1){
alert("Nothing in the table!")
return
}
});
alert("You are still inside the click function")
});
只是在这方面有点麻烦。我想完全退出 jquery 每个循环并单击功能。但是“返回”只是让我脱离了每个循环。如何彻底退出点击功能?
【问题讨论】:
-
$('.mytable tr').length < 1inside .each 循环使用相同的选择器永远不会发生。顺便说一句,您可以在每个循环中使用 return false 来摆脱它。你到底想做什么? -
return 仍然让我留在函数中,我也想在每个循环内的 if 语句中跳出函数
-
这不是指定问题的重复。需要知道如何打破 each() 和函数。
-
我唯一能想到的就是将一个标志标记为真,突破每个标志,然后检查标志并再次返回。看起来很乱。
标签: jquery function loops return each