Im trying to change the speed (setinterval) on this two boxes with onclick function. So far i get the two boxes changing color and i setInterval by 1000(ms) , and now i want to click either one of the boxes and i want them to change the speed of color.
setInterval(
function(){
if (quadraDo == true) {
document.getElementById("demo0").style.background = "red"
document.getElementById("demo1").style.background = "blue";
quadraDo = false;
}
else if (quadraDo == false) {
document.getElementById("demo0").style.background = "blue";
document.getElementById("demo1").style.background = "red";
quadraDo = true;
}
}, 1000);
<div id="demo0" style="position: absolute;background-color: chartreuse ; width: 100px;height: 100px;left: 100px;top: 100px;" onclick="myFunction(this)"></div>
<div id="demo1" style="position: absolute;background-color: chartreuse ; width: 100px;height: 100px;left: 300px;top: 100px;" onclick="myFunction(this)"></div>