Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Remove Node Example</title> </head> <body> <div id="container"> <p id="toBeRemoved">This paragraph will be removed. <button onclick="removeParagraph()">Remove</button></p> </div> <script> function removeParagraph() { let parentNode = document.getElementById('container'); let childNode = document.getElementById('toBeRemoved'); parentNode.removeChild(childNode); } </script> </body> </html>