【发布时间】:2016-11-09 22:39:59
【问题描述】:
所以我有以下标记:
<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 元素,但只有其中一些具有“woocommerce-Price-amount”类的最内层跨度。另一个在“festi-cart-product-price”分类跨度之后一无所有。
我正在尝试使用 jQuery 删除其中没有“woocommerce-Price-amount”跨度的所有 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 -
$('.festi-cart-product-price:not(:has(.woocommerce-Price-amount))').closest('.festi-cart-item').hide();
标签: javascript jquery jquery-selectors