check if HTML style attribute exists with javascript - Javascript DOM

Javascript examples for DOM:Element setAttribute

Description

check if HTML style attribute exists with javascript

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 v  a  2s.co  m*/
var contentWrapper = document.getElementById("contentWrapper");
if(!contentWrapper.getAttribute("style"))
console.log("Empty");
else
console.log("Not Empty");
    }

      </script> 
   </head> 
   <body> 
      <div id="contentWrapper" style="">
         Hello World
      </div>  
   </body>
</html>

Related Tutorials