X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

jQuery hasClass() Method

jQuery HTML/CSS Methods jQuery HTML/CSS Methods

Example

Check if any <p> element has a class named "intro":

$("button").click(function(){
  alert($("p").hasClass("intro"));
});

Try it yourself »

Definition and Usage

The hasClass() method checks if any of the selected elements have a specified class name.

If ANY of the selected elements has the specified class name, this method will return "true".


Syntax

$(selector).hasClass(classname)

Parameter Description
classname Required. Specifies the class name to search for in the selected elements


jQuery HTML/CSS Methods jQuery HTML/CSS Methods


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook