each() 方法为每个匹配元素规定要运行的函数。
例如:输出每个 <li> 元素的文本:
$("button").click(function(){ $("li").each(function(){ alert($(this).text()) }); });
jQuery.each() 函数用于遍历指定的对象和数组。
例如:遍历数组元素
$(function () { $.each([52, 97], function(index, value) { alert(index + ': ' + value); }); })