this is my code and when i am clicking on the button (btnColor) it is only showing last color in an array and not working
help...
var color = ["#222F3E","#F368E0","#EE5253","#ABDE3","#10AC84","#222F3E","#5F27CD","pink"]; var btnColor = document.getElementById("color_change");
btnColor.addEventListener("click", function() {
for(var i = 0; i < color.length; i++) {
document.querySelector("body").style.background = color[i];
}
})
Aucun commentaire:
Enregistrer un commentaire