I've been trying to figure out how to make the div box randomly change color every 1000 millisecond. This is my attempt of function changeColor JavaScript file:
myInterval = setInterval(changeColor, 1000);
var box = document.getElementById("box");
function changeColor() {
var randomColor = Math.floor(Math.random() * 16777215).toString(16);
box.style.backgroundColor = "#" + randomColor;
//let x = document.getElementById('contents');
//x.style.backgroundColor = x.style.backgroundColor == "yellow" ? "pink" : "yellow";
}
<div id="box">This is some text in a div element.</div>