Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <head> <style> #myDIV { border: 1px solid black; margin-bottom: 10px; } </style> </head> <body> <p>Click the button to create a P element with some text, and append it to DIV.</p> <div id="myDIV"> A DIV element </div> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var para = document.createElement("P"); var t = document.createTextNode("This is a paragraph."); para.appendChild(t); document.getElementById("myDIV").appendChild(para); } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_document_createelement4 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:10:40 GMT --> </html>
Result:
Try it Yourself - © w3schools.com