I've got a shopping cart that produces the following code:
<a href="/cart/" class="et-cart-info">
<span>1</span><!-- cart contents number -->
</a>
When a user has an item, I would like the class .yipi added to .et-cart-info. When it's empty and shows <span>0</span> I want the class removed.
I've tried the following code but no avail:
jQuery(function($){
var amount = $(".et-cart-info span").val();
if( amount >= '1' ) {
$(".et-cart-info").addClass('yipi');
}
});
Thanks!
You need to get the text content of the span, not val().