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.
In jQuery, you can select multiple elements by separate it with a comma “,” symbol. In above case, select all elements that have a class name of “class1” and “class2”, and id of “id1”.
You can use the .not()
method or :not()
selector
Code based on your example:
$("ul#list li").not(".active") // not method
$("ul#list li:not(.active)") // not selector
What about $("ul#list li:not(.active)")
?
http://api.jquery.com/not-selector/
You could use this to pick all li
elements without class:
$('ul#list li:not([class])')
Refer to the jQuery API documentation: not() selector and not equal selector.
if (!$(row).hasClass("changed")) {
// do your stuff
}
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