Javascript examples for DOM:Document createTextNode
Creating a list of text node using createTextNode()
<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>