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

javascript$(selector).hasClass(CSS class name);

Example

Let's check if the paragraph has the class www:

html<p id="test" class="www eee">text</p>
javascriptalert( $('#test').hasClass('www') );

See also