The hasClass method
The hasClass method checks for the presence of a CSS class in an element. Returns true if the CSS class is found, and false if not found.
Syntax
$(selector).hasClass(CSS class name);
Example
Let's check if the paragraph has the class www:
<p id="test" class="www eee">text</p>
alert( $('#test').hasClass('www') );
See also
-
methods
addClass,
removeClass,
toggleClass
-
JavaScript property
classList,
with which you can check for the presence of a CSS class in pure JavaScript