Javascript examples for DOM:Document createTextNode
Document createTextNode() Method - Create a <h1> element with some text:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*w w w .j a v a 2s .c o m*/ var h = document.createElement("H1"); var t = document.createTextNode("Hello World"); h.appendChild(t); document.body.appendChild(h); } </script> </body> </html>