jQuery 遍历--siblings() 方法、each() 方法
siblings() 方法
查找每个 p 元素的所有类名为 "selected" 的所有同胞元素(不包括自身):
$("p").siblings(".selected")
each() 方法
each() 方法规定为每个匹配元素规定运行的函数。
语法 $(selector).each(function(index,element))
输出每个 li 元素的文本:
$("button").click(function(){
$("li").each(function(){
alert($(this).text())
});
});

参考地址:http://www.w3school.com.cn/jquery/jquery_ref_traversing.asp

浙公网安备 33010602011771号