Handle Uncaught Type Error for creating an empty div - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Div

Description

Handle Uncaught Type Error for creating an empty div

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Bug fix for stackoverflow</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/* w  ww . j a  v  a  2s .co  m*/
this.elem = document.createElement('div');
document.getElementById('body').appendChild(this.elem);
    }

      </script> 
   </head> 
   <body id="body">    
   </body>
</html>

Related Tutorials