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 > |
Output:
Before:
After:
leave a comment
0 Comments