[问]

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

最新文章

  1. vSphere Client 编辑虚拟机属性的问题
  2. [WCF编程]11.错误:错误类型
  3. DotNetBar中TextBoxDropDown效果图
  4. EF异常:“System.InvalidOperationException”类型的未经处理的异常在 mscorlib.dll 中发生
  5. wpf button的mouse(leftbutton)down/up,click事件不响应解决办法
  6. ACM/ICPC 之 Floyd+记录路径后继(Hdu1385(ZOJ1456))
  7. 【HDU】3853 LOOPS
  8. ios layoutsubView 何时被调用
  9. leetcode@ [134] Gas station (Dynamic Programming)
  10. 【译】velocity
  11. VS2012启用SQLite的Data Provider
  12. LWP::UserAgent - Web user agent class Web 用户agent 类:
  13. 王立平--怎么查看Unity的版本号
  14. Integer自动装箱拆箱bug,创建对象在-128到127
  15. groovy学习(四)io
  16. 4.3 C++虚成员函数表vtable
  17. python 数据类型 之 字典
  18. Powerful array CodeForces - 86D(莫队)
  19. A Chess Game HDU - 1524 (有向图博弈)
  20. vi重要操作指令

热门文章

  1. resteasy经验谈
  2. sqlserver2014内存数据库特性介绍
  3. 读写分离,读写分离死锁解决方案,事务发布死锁解决方案,发布订阅死锁解决方案|事务(进程 ID *)与另一个进程被死锁在 锁 资源上,并且已被选作死锁牺牲品。请重新运行该事务
  4. Jquery中使用定时器setInterval和setTimeout
  5. Apache Mina Filter
  6. getsockname()/getpeername()函数第一次被调用得到0.0.0.0结果
  7. 怎样把XP系统装到USB里?
  8. utf-8与utf-8(无BOM)的区别
  9. 从CRITS发展历史解读结构框架
  10. 转: centos7.5 下 coredns+etcd搭建DNS服务器