Check if Div with specific ID has a certain class - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:hasClass

Description

Check if Div with specific ID has a certain class

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
   </head> 
   <body> 
      <div id="dia" class="wrapper-dropdown-5 active" tabindex="1">
          test // w  ww .j ava2 s.  c  o m
      </div> 
      <script type="text/javascript">
if($("#dia").hasClass("active") == true) {
    console.log("dia, diagnostics..its all the same!!");
}

      </script>  
   </body>
</html>

Related Tutorials