例:
var arr = $(‘#templateForm‘).serializeArray();
$.each(arr,function(k,v){
???if(!v.value){
???????$.dopAlert("请填写所有选项");
???????return false;
???}
});
此方式 return == return true == continue
??return false == break
each循环的方式,无法在循环中结束函数,使用for的方式则可以.
for(var i =0;i<arr.length;i++){
???if(!arr[i].value){
???????$.dopAlert("请填写所有选项");
???????return;
???}
}
jquery each和for循环比较
原文地址:https://www.cnblogs.com/jia-bei/p/8462344.html