How to skip to next iteration in jQuery.each() util?
2024-08-25 22:00:14
[问]
I'm trying to iterate through an array of elements. jQuery's documentation says:
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
最新文章
- vSphere Client 编辑虚拟机属性的问题
- [WCF编程]11.错误:错误类型
- DotNetBar中TextBoxDropDown效果图
- EF异常:“System.InvalidOperationException”类型的未经处理的异常在 mscorlib.dll 中发生
- wpf button的mouse(leftbutton)down/up,click事件不响应解决办法
- ACM/ICPC 之 Floyd+记录路径后继(Hdu1385(ZOJ1456))
- 【HDU】3853 LOOPS
- ios layoutsubView 何时被调用
- leetcode@ [134] Gas station (Dynamic Programming)
- 【译】velocity
- VS2012启用SQLite的Data Provider
- LWP::UserAgent - Web user agent class Web 用户agent 类:
- 王立平--怎么查看Unity的版本号
- Integer自动装箱拆箱bug,创建对象在-128到127
- groovy学习(四)io
- 4.3 C++虚成员函数表vtable
- python 数据类型 之 字典
- Powerful array CodeForces - 86D(莫队)
- A Chess Game HDU - 1524 (有向图博弈)
- vi重要操作指令
热门文章
- resteasy经验谈
- sqlserver2014内存数据库特性介绍
- 读写分离,读写分离死锁解决方案,事务发布死锁解决方案,发布订阅死锁解决方案|事务(进程 ID *)与另一个进程被死锁在 锁 资源上,并且已被选作死锁牺牲品。请重新运行该事务
- Jquery中使用定时器setInterval和setTimeout
- Apache Mina Filter
- getsockname()/getpeername()函数第一次被调用得到0.0.0.0结果
- 怎样把XP系统装到USB里?
- utf-8与utf-8(无BOM)的区别
- 从CRITS发展历史解读结构框架
- 转: centos7.5 下 coredns+etcd搭建DNS服务器