jQuery Attribute Manipulation - addClass() Method
Example
Check if the first <p> element contains the "intro" class:
$("button").click(function(){ alert($("p:first").hasClass("intro")); });
Definition and Usage
The hasClass() method checks if the selected element contains the specified class.
Syntax
$(selector).hasClass(class)
Parameter | Description |
---|---|
class | Required. Specifies the class to be searched for within the specified element. |