Pass a CSS style class as a parameter to function - Javascript DOM

Javascript examples for DOM:Element getAttribute

Description

Pass a CSS style class as a parameter to function

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <style rel="stylesheet">

.A { border: 1px solid red; background-color: white }


      </style> 
      <script>
      function clicked(c) {//from  ww  w  .  ja  va2s . co  m
        console.log(c);
      }
    
      </script> 
   </head> 
   <body> 
      <input type="button" class="A" value="1" onclick="clicked(this.getAttribute('class'))">  
   </body>
</html>

Related Tutorials