each函数不能使用break和continue关键字,替代方法是:
根据如下:
Fortunately there is another way for breaking and continuing a jQuery loop. You can [color=blue]break[/color] a jQuery loop by [color=blue]returning false[/color] in the function argument. A [color=olive]continue[/color] can be implemented by just doing a [color=olive]return without[/color] specifying a return value or by returning any other value than false.
[url=http://www.factsandpeople.com/facts-mainmenu-5/26-html-and-javascript/101-continue-and-break-in-a-jquery-loop]factsandpeople[/url]
$('.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 [color=blue]break[/color] a jQuery loop by [color=blue]returning false[/color] in the function argument. A [color=olive]continue[/color] can be implemented by just doing a [color=olive]return without[/color] specifying a return value or by returning any other value than false.
[url=http://www.factsandpeople.com/facts-mainmenu-5/26-html-and-javascript/101-continue-and-break-in-a-jquery-loop]factsandpeople[/url]