JQuery hasClass() for single and multiple Class
The general syntax for hasClass is as follows
Check single Class
$("selector").hasClass("ClassName")
It will return true if the class is exists else return false
Check Multiple Classes
$("selector").hasClass("ClassName1 ClassName2 ClassName3")
Read More
The general syntax for hasClass is as follows
Check single Class
$("selector").hasClass("ClassName")
It will return true if the class is exists else return false
Check Multiple Classes
$("selector").hasClass("ClassName1 ClassName2 ClassName3")
<html> <head> </head> <body> <input class="found" type="button" value="Found" /> <input class="notfound" type="button" value="Not Found" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script> $(".found").click(function(){ if($(this).hasClass("found")) alert("found"); }); $(".notfound").click(function(){ if($(this).hasClass("notfound")) alert("notfound"); }); </script> </body> </html>