Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery selector does not have specific data attribute

I have an attribute being applied to my dynamically created divs called data-product. Is there a selector I can use to select all divs without a specific data-product value? For instance, if one of the data-product values is "radio," is there a way I can select every div with a data-product value that does not equal radio?

<div data-product="radio" class="product"></div>
<div data-product="television" class="product"></div>
<div data-product="speakers" class="product"></div>

Thanks in advance!

like image 617
user13286 Avatar asked Mar 17 '26 18:03

user13286


1 Answers

Here is what you want

$(".product[data-product!='radio']")

or

$(".product:not([data-product='radio'])")

Hope this helps

like image 162
SarathSprakash Avatar answered Mar 19 '26 06:03

SarathSprakash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!