dimanche 26 février 2017

Javascript condition operators not functioning how I thought they would

I'm trying to make my button change state depending on a boolean. This looks like it would work and I thought it would but it just changes to white. idek why. Please help.

function dropDown(){

var isClicked = false;
var button = document.getElementById("bigbutton");

if(isClicked == false){


    button.style.backgroundColor = "red";
    isClicked = true;
}

if(isClicked == true){

    button.style.backgroundColor = "white";
    isClicked = false;

}

}

Aucun commentaire:

Enregistrer un commentaire