$(selector).each()jquery
語法:$(selector).each(function(index,element){});數組
例子:ide
$("img").each(function(index,element){ console.log(index);// 輸出每一個img的索引值 console.log(element);// [object HTMLImageElement]元素自己 });
注意:index與element倆個的參數位置是不變的spa
$.each.net
each的幾種經常使用的用法:htm
http://www.jb51.net/article/65215.htm對象
$.each()與$(selector).each()不一樣,後者專用於jquery對象的遍歷, 前者可用於遍歷任何的集合(一維數組、多維數組、DOM, JSON 等等)。索引