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 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 ?
- jQuery | .class Selector
- Not class selector in jQuery
- jQuery | Move an element into another element
- How to select an element by name with jQuery?
- How to create a div element in jQuery ?
- How to change the element id using jQuery ?
- jQuery | Create a div element
- jQuery | element + next Selector
- jQuery | element Selector
- How to get focused element using jQuery?
- Get the height of the hidden 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 email@example.com. 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.