mardi 3 mars 2020

switching between two colors is not working

What is it that I am missing here so my page switches between these two colors? Thank you !

var body = document.querySelector("body");
var isBlue = false;

setInterval(function(){
    if(isBlue){
        body.style.background = "green";
    } else {
        body.style.background = "white"
    }
},1000);

Aucun commentaire:

Enregistrer un commentaire