在使用jQuery的each()方法时,如何跳出循环呢?根据官方文档的说明,可以使用return false进行break,如下:

We can break the $.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.
示例:
function checkIsSearchForNothing() {
var result = false;
$("#searchForm").find("input[type='text']").each(function () {
if ($(this).val() != null && $(this).val() != '') {
result = true;
return false;
}
});
return result;
}
参考:

i软糖


最新评论
宝藏网站,差点找不回来了,之前我收藏的发布页打不开了。。。
谢谢您可以
视频资源很全好用,安装后提示更新,安装包站长可以更新一下。
哪个国家成功率高一点?换了十几个了