<html>
<body>
<h1>Element 对象</h1>
<h2>insertAdjacentElement() 方法</h2>
<button onclick="myFunction()">移动</button>
<p>单击“移动”可将红色 span 插入标题内。</p>
<span id="mySpan" style="color:red">我的 span</span>
<h2 id="myH2">我的 Header</h2>
<script>
function myFunction() {
const span = document.getElementById("mySpan");
const h2 = document.getElementById("myH2");
h2.insertAdjacentElement("beforeend", span);
}
</script>
</body>
</html>