add a button and set its text value with createTextNode - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

add a button and set its text value with createTextNode

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(){/* w  w  w  .  j  ava2  s.  com*/
var btn = document.createElement("BUTTON");
var t = document.createTextNode("CLICK ME");
btn.appendChild(t);
document.getElementById('test').appendChild(btn);
    }

      </script> 
   </head> 
   <body>  
      <div id="test">
          add button below 
      </div>   
   </body>
</html>

Related Tutorials