Javascript examples for jQuery Method and Property:not
The not() method returns elements that do not match a certain criteria.
$(selector).not(criteria,function(index));
Parameter | Require | Description |
---|---|---|
criteria | Optional. | a selector expression, a jQuery object or one or more elements to be removed from a group of selected elements. |
function(index) | Optional. | a function to run for each element in a group. |
If function(index) returns true, the element is removed. Otherwise, the element is kept.
index - index position of the element in the set
The following code shows how to Return all <p> elements that do not have the class name "intro":
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").not(".intro").css("color", "red"); });/*from w ww . j av a 2 s . c o m*/ </script> </head> <body> <h1>Welcome to My Homepage</h1> <p>test</p> <p class="intro">test</p> <p class="intro">test</p> <p>test</p> </body> </html>