jQuery hasClass () method
Examples
Check the <p> element contains the "intro" category:
$("button").click(function(){
alert($("p").hasClass("intro"));
});
alert($("p").hasClass("intro"));
});
try it"
Definition and Usage
hasClass () method to check whether the selected element contains the specified class name.
If the selected element contains the specified class, which returns "true".
grammar
$(selector).hasClass(classname)
参数 | 描述 |
---|---|
classname | 必需。规定需要在被选元素中查找的类。 |