Get second class from two available with jQuery - Javascript DOM

Javascript examples for DOM:Element className

Description

Get second class from two available with jQuery

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> 
      <script type="text/javascript">
    $(window).load(function(){//from w ww.j  av a2s .c o m
var elem = document.getElementById('test');
console.log(elem.className.split(' '));
    });

      </script> 
   </head> 
   <body> 
      <div id="test" class="foo bar"></div>  
   </body>
</html>

Related Tutorials