<h1 id="myH1">如何改变标题的样式</h1> <p>点击按钮改变 H1 元素的样式。</p> <button onclick="myFunction()">尝试一下</button> <script> function myFunction() { document.getElementById("myH1").style.color = "red"; }; </script>