I created a function that exchanges colors (pulled from an array ) in certain elements of the page (which are also in array ), changing the colors of the elements one after another. I wanted to do something different, like: Sort the element and color that will be modified. How do I adapt my role to do this?
Example - > link
window.onload = function(){
var box = document.getElementsByClassName('box');
var background = ["#f36", "#C3C", "#fc0", "#FC6", "#9C0"];
cor=0;
div=0;
setInterval(function(){
box.item(div).style.backgroundColor = background[cor];
cor++; div++;
if(cor>=background.length){
cor=0;}
if(div>=box.length){
div=0;}
},2000)
}