Method 1: Using hasClass() method: The hasClass() is an inbuilt method in jQuery which check whether the elements with the specified class name exists or not. It returns a boolean value specifying whether the class exists in the element or not. This can be used to check for multiple classes.
Method 2: Using is() method: This is similar to the above method and can be used to check more attributes if needed. The required element is selected and the class name is passed on like a CSS class selector. It returns a boolean value specifying whether the class exists in the element or not. This can be used to check for multiple classes.
- How to check if an element is hidden in jQuery?
- How to check an element is visible or not using jQuery?
- How to check an element has certain CSS style using jQuery ?
- How to check an HTML element is empty using jQuery ?
- How to find the parent class name with known class in jQuery ?
- How to remove parent element except its child element using jQuery ?
- Not class selector in jQuery
- How to select a div with a certain class using jQuery ?
- jQuery | .class Selector
- jQuery | Move an element into another element
- How to select all elements without a given class using jQuery ?
- How to create a CSS rule or class at runtime using jQuery ?
- jQuery | element Selector
- How to change the element id using jQuery ?
- How to create a div element in jQuery ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.