<html>
<head>
<style>
#myDIV {
width: 300px;
height: 300px;
background-color: coral;
color: white;
}
</style>
</head>
<body>
<h1>使用 JavaScript 更改 background-color</h1>
<p>单击“试一试”按钮将 DIV 元素的背景颜色属性设置为“浅蓝色”:</p>
<button onclick="myFunction()">试一试</button>
<div id="myDIV">
<h1>Hello</h1>
</div>
<script>
function myFunction() {
document.getElementById("myDIV").style.backgroundColor = "lightblue";
}
</script>
</body>
</html>