I’m trying to hide a cart icon on my website when the cart is empty. I’m not an expert in jQuery but I know the basics.
$(document).ready(function() {
if($(".button-icon[data-counter]").is() == "0"){
$(".menu-cart-wrapper").hide();
}else{
$(".menu-cart-wrapper").show();
}
});
```
<div class="menu-cart-wrapper">
<a id="menu-cart__toggle_button" href="#">
<span class="button-text"><span class="woocommerce-Price-amount amount">0 <span class="woocommerce-Price-currencySymbol">kr</span></span></span>
<span class="button-icon" data-counter="0">
<i class="eicon" aria-hidden="true"></i>
<span "screen-only">Cart</span>
</span>
</a>
</div>
With this the button is hidden at all times and I can’t figure out why.
I’ve also tried with the span class “woocommerce-prize etc.” and add .html after with == “0 ” but that didn’t work either.
Plz help!
2
Answers
if you change the data-counter from 1 to 0 it will hide: