<div class="box" id="box"></div>
<button onclick="myfunction()">按钮</button>
<script>
function myfunction() {
var box = document.getElementById("box");
if (box.style.backgroundColor="aqua")
{
box.style.backgroundColor="red";
}
else {
box.style.backgroundColor="black";
}
}
</script>
1<br>