[]

I'm trying to iterate through an array of elements. jQuery's documentation says:

jquery.Each() documentation

Returning non-false is the same as a continue statement in a for loop, it will skip immediately to the next iteration.

I've tried calling 'return non-false;' and 'non-false;' (sans return) neither of which skip to the next iteration. Instead, they break the loop. What am i missing?

【答】

What they mean by non-false is:

return true;

So this code:

var arr = [ "one", "two", "three", "four", "five" ];

$.each(arr, function(i) {

if(arr[i] == 'three') {

return true;

}

alert(arr[i]);

});

Will alert one, two, four, five

 

From: https://stackoverflow.com/questions/481601/how-to-skip-to-next-iteration-in-jquery-each-util

相关文章:

  • 2022-01-18
  • 2021-05-21
  • 2021-07-24
  • 2021-11-27
  • 2021-04-26
  • 2021-11-11
  • 2021-12-12
  • 2020-09-26
猜你喜欢
  • 2021-11-05
  • 2021-05-20
  • 2022-01-04
  • 2022-02-20
  • 2022-12-23
  • 2021-07-12
  • 2022-01-17
相关资源
相似解决方案