<分区>
我正在努力使这个脚本更简洁,因为我将在未来添加更多语句。
x = Math.floor((Math.random() * 9) + 1);
var one = document.getElementById("test");
if(x === 1) {
one.style.backgroundColor = "red";
}
if(x === 2) {
one.style.backgroundColor = "blue";
}
if(x === 3) {
one.style.backgroundColor = "yellow";
}