jQuery :not() Selector Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report The jQuery :not() selector is used to select all the elements which are not selected. Syntax: $(":not(selector)")Parameter: selector: Used to specify that the element is not to be selected. The selector parameter accepts any kind of selector.Example 1: Change the background color of the p element. HTML <!DOCTYPE html> <html> <head> <title>jQuery :not() Selector</title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </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: Example 2: HTML <!DOCTYPE HTML> <html> <head> <title>jQuery :not() Selector</title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"> </script> </head> <body style="text-align:center;"> <h1>GeeksForGeeks</h1> <h2>jQuery | :not() Selector</h2> <p class="GFG-1" style="font-size: 15px; font-weight: bold;"> GFG-1 </p> <p class="GFG-2" style="font-size: 15px; font-weight: bold;"> GFG-2 </p> <p class="GFG-3" style="font-size: 15px; font-weight: bold;"> GFG-3 </p> <button id="button"> Change content </button> <p class="GFG" style="color:green; font-size: 20px; font-weight: bold;"> </p> <script> $("button").on('click', function () { $('p[class^="GFG-"]:not(.GFG-1)').text("new Content"); }); </script> </body> </html> Output: Comment V Vijay Sirra Follow 1 Improve V Vijay Sirra Follow 1 Improve Article Tags : Web Technologies JQuery jQuery-Selectors Explore jQuery Tutorial 7 min read Getting Started with jQuery 4 min read jQuery Introduction 7 min read jQuery Syntax 2 min read jQuery CDN 4 min read jQuery SelectorsJQuery Selectors 5 min read jQuery * Selector 1 min read jQuery #id Selector 1 min read jQuery .class Selector 1 min read jQuery EventsjQuery Events 4 min read jQuery bind() Method 2 min read jQuery blur() Method 1 min read jQuery change() Method 2 min read jQuery EffectsjQuery animate() Method 2 min read jQuery clearQueue() Method 2 min read jQuery delay() Method 2 min read jQuery HTML/CSSjQuery addClass() Method 2 min read jQuery after() Method 1 min read jQuery append() Method 2 min read jQuery TraversingjQuery | Traversing 4 min read jQuery add() method 1 min read jQuery addBack() Method 2 min read Like