Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Add Node Example</title> </head> <body> <button onclick="addNewParagraph()">Add Paragraph</button> <script> function addNewParagraph() { let newNode = document.createElement('p'); newNode.textContent = 'This is a new paragraph.'; document.body.appendChild(newNode); } </script> </body> </html>