Creating div's and textbox using Javascript - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Div

Description

Creating div's and textbox using 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  ww w .j a v  a2s  .c  om*/
var my1 = document.createElement('div');
my1.className = 'a1';
document.getElementsByTagName('body')[0].appendChild(my1);
var my2 = document.createElement('div');
my2.className = 'a2';
my1.appendChild(my2);
var input = document.createElement('input');
input.type = "text";
my2.appendChild(input);
    }

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

Related Tutorials