【发布时间】:2012-07-22 02:28:07
【问题描述】:
<div id="ChosenCategory" class="chosen">
<div class="cat_ch" name="1">
<div class="cat_ch" name="2">
<div class="cat_ch" name="3">
<div class="cat_ch" name="5">
<div class="clear"> </div>
</div>
我想循环通过div.cat_ch 怎么办?
这个失败了:
$("div").each(function () {
alert("FW");
alert($(this).attr("name").val());
});
【问题讨论】:
-
看起来像一个列表。因此,应该是UL/LI,而不是DIV/DIV。此外,如果您在父级上设置
overflow:auto,则可以避免“清除”DIV。 -
$('.cat_ch').each(function(){});
-
我很确定
name不是div元素的有效属性。
标签: javascript jquery loops html each