VOOZH about

URL: https://www.geeksforgeeks.org/jquery/jquery-hasclass-method/

⇱ jQuery hasClass() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

jQuery hasClass() Method

Last Updated : 10 Jul, 2023

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:

Output:

👁 jquery-13

Comment
Article Tags:

Explore