Javascript examples for DOM:Document createElement
Document createElement() Method - Create a <p> element with some text, and append it to the document:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {/* w ww . ja va 2 s . c o m*/ var para = document.createElement("P"); var t = document.createTextNode("This is a paragraph."); para.appendChild(t); document.body.appendChild(para); } </script> </body> </html>