我有一个 HTML 代码:
<li class="item first">
<a class="product-image" title="מדפסת Epson LQ-690" href="http://adcs.gostorego.com/mdpst-epson-lq-690.html">
<img width="135" height="135" alt="מדפסת Epson LQ-690" src="http://s5169dbdce2040.img.gostorego.com/809E82/cdn/media/s5/16/9d/bd/ce/20/40/catalog/product/cache/1/small_image/135x/9df78eab33525d08d6e5fb8d27136e95/images/catalog/product/placeholder/small_image.jpg">
</a>
<h3 class="product-name">
<a title="מדפסת Epson LQ-690" href="http://adcs.gostorego.com/mdpst-epson-lq-690.html">מדפסת Epson LQ-690</a>
</h3>
<div class="price-box">
<span id="product-price-96-widget-new-grid" class="regular-price">
<span class="price" style="display: inline;">0.00 ₪</span>
</span>
</div>
<div class="actions" style="display: block;">
<button class="button btn-cart" onclick="setLocation('http://adcs.gostorego.com/checkout/cart/add/uenc/aHR0cDovL2FkY3MuZ29zdG9yZWdvLmNvbS8,/product/96/')" title="הוסף לסל" type="button">
<span>
<span>הוסף לסל</span>
</span>
</button>
<ul class="add-to-links">
<li>
<span class="separator">|</span>
<a class="link-compare" href="http://adcs.gostorego.com/catalog/product_compare/add/product/96/uenc/aHR0cDovL2FkY3MuZ29zdG9yZWdvLmNvbS8,/">הוסף להשוואה</a>
</li>
</ul>
</div>
</li>
<li class="item">
<a class="product-image" title="מתג HP 1910-48G Switch" href="http://adcs.gostorego.com/mtg-hp-1910-48g-switch.html">
<img width="135" height="135" alt="מתג HP 1910-48G Switch" src="http://s5169dbdce2040.img.gostorego.com/809E82/cdn/media/s5/16/9d/bd/ce/20/40/catalog/product/cache/1/small_image/135x/9df78eab33525d08d6e5fb8d27136e95/images/catalog/product/placeholder/small_image.jpg">
</a>
<h3 class="product-name">
<a title="מתג HP 1910-48G Switch" href="http://adcs.gostorego.com/mtg-hp-1910-48g-switch.html">מתג HP 1910-48G Switch</a>
</h3>
<div class="price-box">
<span id="product-price-109-widget-new-grid" class="regular-price">
<span class="price">2,431.00 ₪</span>
</span>
</div>
<div class="actions" style="display: block;">
<button class="button btn-cart" onclick="setLocation('http://adcs.gostorego.com/checkout/cart/add/uenc/aHR0cDovL2FkY3MuZ29zdG9yZWdvLmNvbS8,/product/109/')" title="הוסף לסל" type="button">
<span>
<span>הוסף לסל</span>
</span>
</button>
<ul class="add-to-links">
<li>
<span class="separator">|</span>
<a class="link-compare" href="http://adcs.gostorego.com/catalog/product_compare/add/product/109/uenc/aHR0cDovL2FkY3MuZ29zdG9yZWdvLmNvbS8,/">הוסף להשוואה</a>
</li>
</ul>
</div>
</li>
<li class="item">
<a class="product-image" title="מתג HP E2510-48 Switch" href="http://adcs.gostorego.com/mtg-hp-e2510-48-switch.html">
<img width="135" height="135" alt="מתג HP E2510-48 Switch" src="http://s5169dbdce2040.img.gostorego.com/809E82/cdn/media/s5/16/9d/bd/ce/20/40/catalog/product/cache/1/small_image/135x/9df78eab33525d08d6e5fb8d27136e95/images/catalog/product/placeholder/small_image.jpg">
</a>
<h3 class="product-name">
<a title="מתג HP E2510-48 Switch" href="http://adcs.gostorego.com/mtg-hp-e2510-48-switch.html">מתג HP E2510-48 Switch</a>
</h3>
<div class="price-box">
<span id="product-price-110-widget-new-grid" class="regular-price">
<span class="price" style="display: inline;">0.00 ₪</span>
</span>
</div>
<div class="actions" style="display: block;">
<button class="button btn-cart" onclick="setLocation('http://adcs.gostorego.com/checkout/cart/add/uenc/aHR0cDovL2FkY3MuZ29zdG9yZWdvLmNvbS8,/product/110/')" title="הוסף לסל" type="button">
<span>
<span>הוסף לסל</span>
</span>
</button>
<ul class="add-to-links">
<li>
<span class="separator">|</span>
<a class="link-compare" href="http://adcs.gostorego.com/catalog/product_compare/add/product/110/uenc/aHR0cDovL2FkY3MuZ29zdG9yZWdvLmNvbS8,/">הוסף להשוואה</a>
</li>
</ul>
</div>
</li>
<li class="item last">
<a class="product-image" title="מתג HP E2510-24G Switch" href="http://adcs.gostorego.com/mtg-hp-e2510-24g-switch.html">
<img width="135" height="135" alt="מתג HP E2510-24G Switch" src="http://s5169dbdce2040.img.gostorego.com/809E82/cdn/media/s5/16/9d/bd/ce/20/40/catalog/product/cache/1/small_image/135x/9df78eab33525d08d6e5fb8d27136e95/images/catalog/product/placeholder/small_image.jpg">
</a>
<h3 class="product-name">
<a title="מתג HP E2510-24G Switch" href="http://adcs.gostorego.com/mtg-hp-e2510-24g-switch.html">מתג HP E2510-24G Switch</a>
</h3>
<div class="price-box">
<span id="product-price-111-widget-new-grid" class="regular-price">
<span class="price">2,696.00 ₪</span>
</span>
</div>
<div class="actions" style="display: block;">
<button class="button btn-cart" onclick="setLocation('http://adcs.gostorego.com/checkout/cart/add/uenc/aHR0cDovL2FkY3MuZ29zdG9yZWdvLmNvbS8,/product/111/')" title="הוסף לסל" type="button">
<span>
<span>הוסף לסל</span>
</span>
</button>
<ul class="add-to-links">
<li>
<span class="separator">|</span>
<a class="link-compare" href="http://adcs.gostorego.com/catalog/product_compare/add/product/111/uenc/aHR0cDovL2FkY3MuZ29zdG9yZWdvLmNvbS8,/">הוסף להשוואה</a>
</li>
</ul>
</div>
</li>
</ul>
现在我想在每个 li 中查找价格类是否包含 = 0.00。如果它是真的那么隐藏类价格并隐藏 div 类操作。
这是我的 jQuery 代码:
$j('.item').each(function(){
if($j(this).find(".price:contains('0.00')")){
$j(this).find(".price:contains('0.00')").hide();
$j(this).find(".actions").hide();
}
});
在执行此代码时,如果它是 0.00,它会隐藏价格,但是当隐藏 .actions 时,它显然会隐藏所有 li 中的所有 .actions,但是我只想隐藏 .price 如果它的 0.00 和它的 .actions