如何在jQuery each()循环中使用Continue? [英] How to use continue in jQuery each() loop?

查看:531
本文介绍了如何在jQuery each()循环中使用Continue?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我正在使用AJAX调用。我想在此jQuery循环中使用 break continue

In my application i am using AJAX call. I want to use break and continue in this jQuery loop.

$('.submit').filter(':checked').each(function() {

});


推荐答案

我们都可以 break $(selector).each()循环和 $。each()循环在特定迭代中通过回调函数返回 false 。返回 non-false for 循环中的continue语句相同;

We can break both a $(selector).each() loop and a $.each() loop at a particular iteration by making the callback function return false. Returning non-false is the same as a continue statement in a for loop; it will skip immediately to the next iteration.

return false; // this is equivalent of 'break' for jQuery loop

return;       // this is equivalent of 'continue' for jQuery loop






请注意, $(selector).each() $。each() 是不同的函数。

参考文献:

这篇关于如何在jQuery each()循环中使用Continue?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆