A body
tag has the following style:
background-color: rgb(114, 119, 125);
With JavaScript, I want to test what is the background color and change it accordingly.
setTimeout(function() {
if (document.querySelector("body").style.backgroundColor = "red") {
document.querySelector("body").style.backgroundColor = "black"
} else {
document.querySelector("body").style.backgroundColor = "blue"
};
}, 1000);
Because rgb(114, 119, 125)
is not Red, I would expect to get a Blue background, but instead I get a Black background.
Why do I have this problem and how would you suggest to solve it?