Reputation: 68820
$('.product-nav li a').click(function() {
$('.product-nav li').removeClass('active');
$(this).parent().addClass('active');
if( $(this).hasClass('tshirts') ){
$('product').hide();
$('.product.tshirt').show();
}
});
.. active class is assigned correctly but the products are not hidden/shown as desired because I think the if condition is not recognized on click?
Upvotes: 0
Views: 1072
Reputation: 207557
What element is product?
$('product').hide();
You are missing the .
$('.product').hide();
Upvotes: 7
Reputation: 2923
It shouldn't have a problem reaching your condition.
You seem to have a typo though. On line #5, you're running a jQuery selector for <product>
elements. Do you mean to select elements with the class product
? (i.e. $('.product')
)?
Upvotes: 1
Reputation: 5699
$('.product-nav li').removeClass('active');
$(this).parent().addClass('active');
The 1st line removes it, the 2nd line adds it back in.
Do you mean:
$(this).parent().addClass('tshirts');
Upvotes: 0