所以我有以下的標記:刪除不具有特定descendandt元素在jQuery中的所有元素
<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 - 價格 - 最裏面的跨度數量「類。另一個在「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();
});
});
我一直在嘗試使用:不是選擇器,但它似乎並沒有產生任何東西。我真的不確定它出錯的地方。
你們中的任何一個都可以發現我的代碼出錯的地方,或者它對於一個簡單的解決方案來說是完全沒有希望的方法嗎?
錯字,在'tr'類是'festi - 車 - item',不'festi推車。商品' –
'$('。festi-cart-product-price:not(:has(.woocommerce-Price-amount))')。close('。festi-cart-item')。hide();' – Rayon