jquery each遍历判断返回false方法
文章目录
在jquery each中遍历返回false失效,解决办法,用变量解决:
var num = 0;
$(".box").find("input[type='text']").each(function () {
if($(this).val() == "") {
// alert("项目标题不能为空!");
num++;
}
})
if(num>0){
alert("项目标题不能为空!");
return;
}
//判断选中标题是否为空的checkbox
var numb = 0;
$(":checkbox").each(function(index, el) {
if($(el).is(':checked')){
title = $(el).siblings("input").val();
if(title == ""){
numb++;
}
}
});
if(numb>0){
alert("图片名称不能为空!");
return;
}
转载于猿2048:➭《jquery each遍历判断返回false方法》
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论