jQuery | :not() Selector
The :not() selector is used to select all the elements which are not selected.
Syntax
$(":not(selector)")
Parameter:
- selector: Used to specify that the element not to be selected. The selector parameter accept any kind of selector.
Example: Change background color of p element.
<!DOCTYPE html> <html> <head> <script src= </script> <script> $(document).click(function() { $("p:not(.intro)").css( "background-color", "green"); }); </script> </head> <body> <center> <h1>Geeks for Geeks</h1> <p class="intro"> A Computer Science Portal for Geeks </p> <p>jQuary :not selector </p> <p>I change my background color </p> <p>language option</p> <ul id="choose" style="width:5em; margin:0 auto;"> <li> JAVA </li> <li> C++ </li> <li> PYTHON </li> </ul> <button> Change color </button> </center> </body> </html> |
chevron_right
filter_none
Output:
Before:

After:

Recommended Posts:
- jQuery | :has() Selector with example
- jQuery | :gt() Selector
- jQuery | :contains() Selector
- jQuery | :lt() Selector
- jQuery | :even Selector
- jQuery | :first Selector
- jQuery | :odd Selector
- jQuery | :last Selector
- jQuery | * Selector
- jQuery | #id Selector
- jQuery | :submit Selector
- jQuery | [attribute$=value] Selector
- jQuery | :parent Selector
- jQuery | :file Selector
- jQuery | :last-child Selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



