$.each()循环跳出,应该用return 来返回
在each代码块内不能使用break和continue,要实现break和continue的功能的话,要使用其它的方式:
break----用return false;
continue --用return true;
如果想要使用return终止方法的话,要用try catch 方式,代码如下
- try{
- $.each(Array,function(key,val) {
- if( aaa){
- throw(‘‘);
- }
- })
- }catch(e){
- return; //在这里return
- }
原文地址:https://www.cnblogs.com/fanjingfeng/p/9270260.html
时间: 2024-08-30 17:54:58