I am trying to make a script that changes the header's color every second, I have made a function that styles a HTML element with a random color whenever it's called, and when I use the setInterval(); it does not work!
function randomColor(elementId) {
var colors = ["red","green","blue","purple","lightblue","cyan","yellow","brown","pink","grey"];
var randomNumber = Math.floor(Math.random() * 10) + 1;
document.getElementById(elementId).style.color = colors[randomNumber];
}
setInterval(randomColor("Header"), 1000);
Can someone help? thanks!
Note: When I refresh the page it only changes the color once.