Creating a list of text node using createTextNode() - Javascript DOM

Javascript examples for DOM:Document createTextNode

Description

Creating a list of text node using 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">
function myFunction() {//from   w  ww . ja v a 2 s .c o m
    var name = 'abc',
        node = document.createTextNode(name);
    document.getElementById('latest').appendChild(node);
}

      </script> 
   </head> 
   <body> 
      <p>
         Latest text: 
         <span id="latest"></span>
      </p> 
      <a href="#" onclick="myFunction()">Click to run</a>  
   </body>
</html>

Related Tutorials