Jquery与form表单 $.each 中 return的使用
function check() {
var result = true;
$(".uploadfile").each(function () {
if ($(this).val() == "") {
alert("图片不能为空!");
//$('#from1').attr({ onsubmit: "return false" });
result = false;
return false;//break;
}
});
if (!result)
return result;//check() 返回 false
}
//$.each()的 break -> return false
//$.each()的 continue -> return ture
<form onsubmit = "return check();>