jQuery hasClass() method
Example
Checks
Check whether the element contains the "intro" class:
$
(
"
button
"
)
.
click
(
function
(
)
{
alert
(
$
(
"
p
"
)
.
hasClass
(
"
intro
"
)
)
;
}
)
;
Try it »
Definition and Usage
The hasClass() method checks whether the selected elements contain the specified class name.
If the selected element contains the specified class, this method returns "true".
Syntax
$(
selector
).hasClass(
classname
)
| Parameters | Description |
|---|---|
| classname | Required. Specifies the class to look for in the selected elements. |
jQuery HTML/CSS methods