Use appendChild function to add text node - Javascript DOM

Javascript examples for DOM:Element appendChild

Description

Use appendChild function to add text node

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script type="text/javascript">
function append()//from  w w  w.j  a  v  a2 s.  c o m
{
var node = document.getElementById("history");
node.appendChild(document.createTextNode("text"));
}
window.onload = append;

      </script> 
      <div id="history"></div>  
   </body>
</html>

Related Tutorials