Create a <p> element with some text:
Click the button to create a P element with some text, and append it to DIV.
<!DOCTYPE html> <html> <head> <style> #myDIV {//from ww w.ja va 2s .c o m border: 1px solid black; margin-bottom: 10px; } </style> </head> <body> <div id="myDIV"> A DIV element </div> <button onclick="myFunction()">Test</button> <script> function myFunction() { var para = document.createElement("P"); para.innerHTML = "This is a paragraph."; document.getElementById("myDIV").appendChild(para); } </script> </body> </html>