1. 修改 HTML 內容
<!DOCTYPE html> <html> <body> <p id = "change">原始內容</p> <script> document.getElementById("change").innerHTML = "修改過後的內容"; </script> </body> </html>
2. 修改 HTML 屬性
<!DOCTYPE html> <html> <body> <a id = "change1" href = "https://www.baidu.com">這是百度</a> <br> <a id = "change2" href = "https://www.baidu.com">這是淘寶</a> <script> document.getElementById("change2").href = "https://www.taobao.com"; </script> </body> </html>