執行 ❯
建立您
自己的
網站
×
改變方向
儲存程式碼
更改主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <body> <h2>JavaScript HTML DOM</h2> <h3>Remove an HTML Element.</h3> <div> <p id="p1">This is a paragraph.</p> <p id="p2">This is another paragraph.</p> </div> <button onclick="myFunction()">Remove Element</button> <script> function myFunction() { document.getElementById("p1").remove(); } </script> </body> </html>