Create input and set its attribute value: type, default value, name - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form Event

Description

Create input and set its attribute value: type, default value, name

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(){//ww w.  j ava2s . co m
 var formElement = document.createElement('input');
formElement.type = 'text';
formElement.defaultValue = "test";
formElement.name="test2";
console.log(formElement);
    }

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

Related Tutorials