I want to change the colors of the buttons automatically with the setTimeout or the setInterval when clicking, but it happens that they change all at once and not one by one, synchronized...
What do I have to modify to get the result I want? using the classic for loop nothing about for each, I know they are the same but so far I am learning and familiarizing myself with for
function color() {
var umder = document.querySelectorAll(".button > button");
setInterval(function(){
for (var i = 0; i < umder.length; i++) {
umder[i].style.backgroundColor = "red";
}
}, 2000);
}
color();
<div class="button">
<button>1</button>
<button>2</button>
<button>3</button>
</div>
you could do it with a setTimeout since the set interval is executed from time to time and it will change everyone try this