The loop function of jquery is each()
End jumping out of the loop: return false, equivalent to break;
End this cycle and enter the next cycle: return true, which is equivalent to continue.
Example (1)
function MyEach(obj, text) {
var val = "";
$("#option").each(function(){
if($(this.text() == text)) {
val = $(this).val();
return false;
}
});
return val;
}
Example (2)
var flag = true;
$('input[type="file"][name="fileField"]').each(function(){
if($(this).val() != "") {
debugger;
$.messager.alert('提示:',"请先上传附件","info");
flag = false;
return false;
}
});
if(!flag)
return;