Create a <p> element and append it to a <div> element:
Click the button to create a P element with some text, and append it to DIV.</p>
<!DOCTYPE html> <html> <head> <style> #myDIV {// ww w. j a v a2 s .c om 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>