<!DOCTYPE html> <html> <body> <h1>Element 对象</h1> <h2>removeChild() 方法</h2> <p>单击“删除”可从列表中溢出 id="myLI" 的元素。</p> <button onclick="myFunction()">删除</button> <ul> <li>Coffee</li> <li id="myLI">Tea</li> <li>Milk</li> </ul> <script> function myFunction() { const element = document.getElementById("myLI"); element.parentNode.removeChild(element); } </script> </body> </html>