Site icon Shaharia's Blog

How to Check existing class name of an element in jQuery

To check and find the existing class name of an element inside HTML by jQuery you can use hasClass().

if($('#elm').hasClass('classname'))
 {
?  //Do whatever you want
 }
 else
 {
   //Do whatever you want
 }

http://api.jquery.com/hasClass/

Exit mobile version