each函数不能使用break和continue关键字,替代方法是:
- $('.container').each(function(i){
- if($(this).attr('name')=="continue"){
- return ;//实现continue功能
- }else if($(this).attr('name')=="break"){
- return false;//实现break功能
- }
- })
根据如下:
Fortunately there is another way for breaking and continuing a jQuery loop. You can break a jQuery loop byreturning false in the function argument. A continue can be implemented by just doing a return withoutspecifying a return value or by returning any other value than false.
Fortunately there is another way for breaking and continuing a jQuery loop. You can break a jQuery loop byreturning false in the function argument. A continue can be implemented by just doing a return withoutspecifying a return value or by returning any other value than false.