Rav*_*ant 147 each jquery for-loop
在我的应用程序中我使用ajax调用.我想在这个jquery循环中使用break并继续.
$('.submit').filter(':checked').each(function() {
});
Run Code Online (Sandbox Code Playgroud)
Jay*_*ram 305
通过使回调函数返回,我们可以在特定的迭代中打破$(selector).each()循环和$.each()循环false.返回non-false与for循环中的continue语句相同; 它将立即跳到下一次迭代.
return false; // this is equivalent of 'break' for jQuery loop
return; // this is equivalent of 'continue' for jQuery loop
Run Code Online (Sandbox Code Playgroud)
注意:$(selector).each()并且$.each()是不同的功能.
引用:$(selector).each()和$ .each() $ .each(selector)和$(selector).each()之间有什么区别
小智 21
$('.submit').filter(':checked').each(function() {
//This is same as 'continue'
if(something){
return true;
}
//This is same as 'break'
if(something){
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
我们可以通过使回调函数返回false来在特定迭代中中断$ .each()循环.返回非false与for循环中的continue语句相同; 它将立即跳到下一次迭代.- jQuery.each()| jQuery API文档
| 归档时间: |
|
| 查看次数: |
89452 次 |
| 最近记录: |