<!DOCTYPE html> <html> <body> <h1>Element 对象</h1> <h2>remove() 方法</h2> <p id="demo">单击“删除”,该段落将从 DOM 中删除。</p> <button onclick="myFunction()">删除</button> <script> function myFunction() { const element = document.getElementById("demo"); element.remove(); } </script> </body> </html>