Get CSS for style attribute from an element - Javascript DOM

Javascript examples for DOM:Element getAttribute

Description

Get CSS for style attribute from an element

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from   w w w.  j  a va  2s .  c  om*/
(function getStyles(){
    var styles = document.getElementById("t1").getAttribute("style");
    console.log(styles);
})();
    }

      </script> 
   </head> 
   <body> 
      <div id="t1" style="border-style: solid; border-width: 10px; border-color: red; height: 100px; width: 100px;">
         Hello
      </div>  
   </body>
</html>

Related Tutorials