【发布时间】:2014-08-23 08:04:41
【问题描述】:
我正在尝试遍历一些列表项并检查子字段“.price”的值。 这是我正在使用的代码。
var item = jQuery(".product_overview li")
jQuery(item).each(function() {
var itemPrice = jQuery(".product_overview li .price").html();
alert(itemPrice);
});
但是每个循环都给了我第一个孩子的价值..
HTML
<ul class="product_overview">
<li><span class="price">20</span></li>
<li><span class="price">40</span></li>
<li><span class="price">60</span></li>
</ul>
【问题讨论】:
-
旁注:你不需要从
item构造另一个jQuery对象,因为它已经是一个:item.each(function() { ...