Ken*_*ler 10

return false.each()循环内使用完全爆发.返回任何非虚假的东西就像continue:它停止当前迭代并直接跳到下一个迭代.

var myArr = [1,2,3,4,5,6,7];
$.each( myArr, function(){
  // Skip on three
  if( this === 3 ) return true;
  // Abort on five
  if( this === 5 ) return false;
  doStuff( this ); // never for 3, 5, 6 or 7
});
Run Code Online (Sandbox Code Playgroud)


Emm*_*ett 5

http://api.jquery.com/jQuery.each/

我们可以通过使回调函数返回false来在特定迭代中中断$ .each()循环.返回非false与for循环中的continue语句相同; 它将立即跳到下一次迭代.