$().each 在dom处理上面用的较多。如果页面有多个input标签类型为checkbox,对于这时用$().each来处理多个checkbook,例如:

$(“input[name=’ch’]”).each(function(i){
if($(this).attr(‘checked’)==true)
{
//一些操作代码
}
回调函数是可以传递参数,i就为遍历的索引。 遍历一个数组通常用$.each()来处理  例如:

$.each([{name:"limeng",email:"xfjylimeng"},{name:"hehe",email:"xfjylimeng"}],function(i,n)
{
alert("索引:"+i+"对应值为:"+n.name);
});

参数i为遍历索引值,n为当前的遍历对象.

var arr2 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
$.each(arr2, function(i, item){
alert(item[0]);
});
输出:1   4   7

最新文章

  1. wordpress多站点配置
  2. Winform TreeList递归绑定树节点
  3. Windows nexus 启动失败
  4. php扩展redis
  5. hdu 1270 小希的数表
  6. 几个常用道的macro
  7. DEV 打印gridcontrl
  8. 工作流--JBPM核心服务及表结构
  9. Mavnen的几种依赖关系
  10. springboot(一)
  11. java的断言(assert)
  12. Vue学习4:class与style绑定
  13. ae:org.apache.shiro.authc.AuthenticationException: Authentication token of type [class org.apache.shiro.authc.UsernamePasswordToken] could not be authenticated by any configured realms. Please ensure
  14. 浅谈.net中数据库操作事务
  15. java 中文繁简体转换工具 opencc4j
  16. Linux系统文件压缩与备份(5)
  17. python(36):python日志打印,保存,logging模块学习
  18. host.conf 文件
  19. zabbix出现中文不能选的情况
  20. jQuery学习-键盘事件

热门文章

  1. VC6工程因行尾格式无法转换到VS2015
  2. linux 备份svn
  3. flask中cookie和session介绍
  4. bzoj 2282 消防
  5. 关于 self = [super init];
  6. DbEntry 简单实现
  7. spring源码学习之:springAOP实现底层原理
  8. FastAdmin 学习线路 (2018-09-09 增加 Layer 组件)
  9. python 函数名,闭包
  10. bzoj 2555 SubString——后缀自动机+LCT