Description
The .hasClass() method checks if any of the selected elements have a specified class.
If ANY of the selected elements has the specified class, this method will return "true".
v1.2
This method has the form:
.hasClass(class)
Parameter | Description |
---|---|
class | (required) Specifies the class to search for in the selected elements |
Return Value
This form returns a Boolean object.
Examples
Check if any p element has an "intro" class:
$("button").click(function(){
alert($("p").hasClass("intro"));
});