each用法的总结

1、选择器+遍历

  $('div').each(function (i){

     i就是索引值

     this 表示获取遍历每一个dom对象

  });

 

2、选择器+遍历

  $('div').each(function (index,domEle){

     index就是索引值

    domEle 表示获取遍历每一个dom对象

  });

 

3、更适用的遍历方法

  1)先获取某个集合对象

  2)遍历集合对象的每一个元素

   var d=$("div");

   $.each(d,function (index,domEle){

     d是要遍历的集合

     index就是索引值

     domEle 表示获取遍历每一个dom对

   });

原文地址:https://www.cnblogs.com/zwhbk/p/6272955.html