运行 ❯
获取您的
自己
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>Set outerText</h1> <p>When setting the outerText, the entire element gets replaced.</p> <p>Click the button to change (and remove) the h1 element:</p> <button onclick="myFunction()">Change Header</button> <script> function myFunction() { const x = document.getElementsByTagName("h1")[0]; x.outerText = "Changed content!"; } </script> </body> </html>