我想让颜色在某个词上不断变化。谁能帮我?这是我到目前为止所拥有的:
var myColor = document.getElementById("color");
var colorArray = ["#ffd464", "#2980b9", "#DC143C", "#3CB371", "#DA70D6", "#9400D3"];
var colorIndex = 0;
function changeColor() {
myColor.style.color('color', colorArray[colorIndex]);
colorIndex++;
if (colorIndex >= colorArray.length) {
colorIndex = 0;
}
}
setInterval(changeColor, 5000);
谢谢!