jQuery hasClass() Method Last Updated : 10 Jul, 2023 Suggest changes Share Like Article Like Report The hasClass() is an inbuilt method in jQuery which check whether the elements with the specified class name exist or not. Syntax: $(selector).hasClass(className);Parameter: It accepts a "className" parameter which specifies the class name needed to search in the selected element. Return Value: It returns true if the search is successful otherwise false. jQuery code to show the working of this method: 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 () { $("button").click(function () { alert($("p").hasClass("find")); }); }); </script> <style> .find { font-size: 120%; color: green; } body { width: 80%; height: 200px; padding: 20px; display: flex; justify-content: center; } div { width: 600px; height: 200px; border: 2px solid green; } </style> </head> <body> <div> <h1>Heading 1</h1> <p class="find"> Geeks for Geeks !. </p> <p> This is normal paragraph. </p> <button>Click me!</button> </div> </body> </html> Output: K kundankumarjha Follow Article Tags : Web Technologies JQuery jQuery-Methods Explore jQuery Tutorial 8 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 My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like