Question

$('.products .product-category[data-slug="'+slug+'"] .expander').slideDown();

I have the above selector but I am trying to add another selector elsewhere that select all BUT [data-slug="'+slug+'"] and slide them up using .slideUp()

Thanks

Was it helpful?

Solution

You can use :not selector

$('.products .product-category:not([data-slug="'+slug+'"]) .expander').slideUp()

OTHER TIPS

Try .not()

$('.products .product-category').not('[data-slug="'+slug+'"] .expander').slideUp();


:not()

$('.products .product-category:not([data-slug="'+slug+'"] .expander').slideUp();

Attribute Not Equal Selector [name!="value"]

$('.products .product-category[data-slug!="'+slug+'"] .expander').slideDown();

Try to use .not():

$('.products').not('.product-category[data-slug="'+slug+'"] .expander').slideUp();

Try .not():

$('.products .product-category').not('[data-slug="'+slug+'"]').find('.expander').slideUp();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top