<!DOCTYPE html> <html> <body> <h1>JavaScript HTML DOM</h1> <p>删除 HTML 元素:</p> <div> <p id="p1">This is a paragraph.</p> <p id="p2">This is another paragraph.</p> </div> <button onclick="myFunction()">删除元素</button> <script> function myFunction() { document.getElementById("p1").remove(); } </script> </body> </html>