function changeColor(color) {
document.body.style.backgroundColor = color;
}
When I open my html file, I have two buttons, but when I click it, the background changes only for a second to either red or blue depending on which button I’ve pressed and then goes back being white. How do I make it so that the color stays red and will only change if I hit blue button again?
if you also added a cookie into the mix it could remember the last color selected and on the next visit and/or page you can retain the colour they selected. Additionally you could even change stylesheets and have a completely different look selected by the user.