【发布时间】:2015-12-13 13:33:37
【问题描述】:
在 div 循环中定位特定 div 时遇到问题。
我下面的代码是在页面上重复多次的单个项目。如果 edd_price 类的 span 中包含文本“Free”,我想隐藏该项目的 div 类“vat”。
<div class="product-thumb">
<a href="http://tb.eldo.co.uk/downloads/achieving-sales-on-the-telephone-sample-notes/">
<div class="thum">
<img width="185" height="150" src="blah"/>
</div>
<div class="title">Title goes here</div>
<div class="price">
<span class="edd_price">Free</span>
</div>
<div class="vat clear">
price excluding 20% vat
</div>
</a>
我尝试过的所有东西都不会影响页面上的所有项目,这是我认为应该起作用的 -
$(document).ready(function() {
if ($(".edd_price").contains("Free")) {
$(this).parent().next('div.vat').hide();
}
});
【问题讨论】: