在使用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;
}
参考:
最新评论
没有磁力吗
不行,这个版本4K还是限速~
搞笑了,官网打不开的机场,检验倒数到0直接卡死了
都是ip6的,有ip4的吗?老电视不支持ip6