I'm trying to make a button that switchs the mode from light to dark. By default it's light mode, but for some reason, when I switch to dark mode, it works, but it won't switch back to light mode.
Here is the javascript code:
const modeButton = document.getElementById('light-dark-btn');
modeButton.addEventListener('click', ()=> {
if(document.body.style.backgroundColor = 'rgb(255,255,255)'){
document.body.style.backgroundColor = 'rgb(18,18,18)';
document.body.style.color = 'rgb(255,255,255)';
}else if((document.body.style.backgroundColor = 'rgb(18,18,18)')){
document.body.style.backgroundColor = 'rgb(255,255,255)';
document.body.style.color = 'rgb(0,0,0)';
}
})
I'm trying to make a button that switchs the mode from light to dark.