<!DOCTYPE html> <html> <body> <h1>Element 对象</h1> <h2>insertAdjacentHTML() 方法</h2> <button onclick="myFunction()">插入</button> <p>单击“插入”可在标题后插入一个段落。</p> <h2 id="myH2">我的标题</h2> <script> function myFunction() { const h2 = document.getElementById("myH2"); let html = "<p>我的新段落。</p>"; h2.insertAdjacentHTML("afterend", html); } </script> </body> </html>