I have a purple button. It becomes green onclick, even if in the if statement instead of purple I wrote Yellow. Then it remains green, although the else if statement should make it purple again onclick. What's wrong with my code?
`var m = document.getElementById ("buttonanimation");
function changecolor(){
if (m.style.backgroundColor="yellow"){
m.style.backgroundColor="green";
} else if (m.style.backgroundColor="green"){
m.style.backgroundColor="purple";
}
}`
Aucun commentaire:
Enregistrer un commentaire