Change element width and height via CSS style - Javascript CSS Style Property

Javascript examples for CSS Style Property:height

Description

Change element width and height via CSS style

Demo Code

ResultView the demo in separate window

<!doctype html>
<html>
   <head></head>
   <body> 
      <div id="box">
          Hello! //from   w  ww . j  a va 2s  . c om
      </div> 
      <script>
  (function changeSize() {
    document.getElementById('box').setAttribute("style","display:block;width:300px;background-color:blue;");
    document.getElementById('box').style.width='300px';
  })()

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

Related Tutorials