<html>
<body>
<h1>Element 对象</h1>
<h2>outerHTML 属性</h2>
<p id="myP">我是一个段落!单击“更改”可用标题替换我。</p>
<button onclick="myFunction()">更改</button>
<script>
function myFunction() {
const element = document.getElementById("myP");
element.outerHTML = "<h2>This is a h2 element.</h2>";
}
</script>
</body>
</html>