jQuery [attribute] Selector Last Updated : 27 Jun, 2023 Comments Improve Suggest changes 2 Likes Like Report The [attribute] Selector is an inbuilt selector in jQuery, used to select all the elements with the specified attribute. Syntax: $("[attribute_name]") Parameter: attribute_name: It is the required parameter which specify the attribute to be select. Example-1: html <!DOCTYPE html> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <script> $(document).ready(function() { $("[class]").css("color", "green"); }); </script> </head> <body> <center> <!-- Class attribute--> <h3 class>GeeksforGeeks</h3> <p>A computer science portal for geeks</p> <!--id attribute--> <p id>Geek1</p> <!--class attribute--> <p class>Geek2</p> <p>Geek3</p> <!--class attribute--> <div class> Thank You! </div> </center> </body> </html> Output: In the above example, all the elements with the specified attribute (class) are formatted into green color i.e, "GeeksforGeeks", "Geek2" and "Thank You!". Example-2: html <!DOCTYPE html> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <script> $(document).ready(function() { $("[class]").css("color", "green"); }); </script> </head> <body> <center> <!-- Class(demo) attribute--> <h3 class="demo">GeeksforGeeks</h3> <p>A computer science portal for geeks</p> <!--id attribute--> <p id>Geek1</p> <p>Geek2</p> <!--class(test) attribute--> <p class="test">Geek3</p> <!--class(sample) attribute--> <div class="sample"> Thank You! </div> </center> </body> </html> Output: In the above example, all the elements with the specified attribute (class) are formatted into green color rather considering the value of the attribute. "GeeksforGeeks", "Geek3" and "Thank You!" are formatted. Create Quiz Comment V vaishalichauhan3003 Follow 2 Improve V vaishalichauhan3003 Follow 2 Improve Article Tags : JQuery 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