I have this selector below where it ignores any li
with the class show-all-boxes
$('.boxes li:not([class="show-all-boxes"]) input:checkbox')
What is the best way of adding multiple classes to be ignored by the selector? An example of this that I thought would work but it doesn't is:
$('.boxes li:not([class="show-all-boxes, show-all-circles, show-all-triangles"]) input:checkbox')
We aren't limited to only two here, we can combine as many classes and IDs into a single selector as we want.
In CSS, to exclude a particular class, we can use the pseudo-class :not selector also known as negation pseudo-class or not selector. This selector is used to set the style to every element that is not the specified by given selector. Since it is used to prevent a specific items from list of selected items.
There are no logical combinators with :not() , like and or or , but you can chain them, which is effectively like and . The :not() selector doesn't add any specificy by itself, but what is inside does, so :not(.
To select element that does not have specific class with JavaScript, we can use the document. querySelector method with the :not pseudoclass. const li = document. querySelector("li:not(.
The :not selector can take multiple CSS selectors as arguments ( http://api.jquery.com/not-selector ). E.g.
$('div:not(.a,.b)').empty()
http://jsfiddle.net/HFfcP/
try this :
$('.boxes li').not(".show-all-boxes, .show-all-circles, .show-all-triangles").find('input:checkbox')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With