所以,我有以下标记:
<div class="festi-cart-products-content">
<table class="festi-cart-list">
<tbody>
<tr class="festi-cart-item ">
<td class="festi-cart-product-img">
</td>
<td class="festi-cart-product-title">
<a class="festi-cart-title" href="">product name</a><br>
<span class="festi-cart-product-price">
<span class="woocommerce-Price-amount amount"></span>
</span>
</td>
</tr>
</tbody>
</table>
</div>
有多个tr元素,但只有一些内部最深层的span具有“woocommerce-Price-amount”类。其他的在“festi-cart-product-price”类的span后面没有内容。
我正在尝试使用jQuery删除所有不包含“woocommerce-Price-amount” span的tr元素。
jQuery( document ).ajaxComplete(function() {
jQuery(".festi-cart-product-price:not(:has(>span))").each(function(){
jQuery(this).parent('tr.festi-cart.item').hide();
});
});
我一直在尝试使用:not选择器,但似乎没有产生任何结果。我真的不确定哪里出错了。
你们中有人能发现我的代码哪里出了问题吗?或者这是一个对于简单解决方案来说完全绝望的方法?
tr
上的类应该是festi-cart-item
,而不是festi-cart.item
。 - Rory McCrossan$('.festi-cart-product-price:not(:has(.woocommerce-Price-amount))').closest('.festi-cart-item').hide();
- Rayon