<!DOCTYPE html> <html> <body> <h1>Element 对象</h1> <h2>insertAdjacentText() 方法</h2> <p>单击“插入”可在标题中插入一些文本:</p> <button onclick="myFunction()">插入</button> <h2 id="myH2">我 Header</h2> <script> function myFunction() { const h2 = document.getElementById("myH2"); let text = "我的插入文本"; h2.insertAdjacentText("beforeend", text); } </script> </body> </html>