Currently, I am attempting to change the color scheme of the page by adjusting the :root variables using a function called changeBackgrondColor(). This function is then assigned to the fontAwesome moon "button". However, when I click on the moon, the page changes colors briefly before returning to its original state.
var r = document.querySelector(':root');
var rootStyles = getComputedStyle(r);
function changeBackgroundColor(){
r.style.setProperty('--clr-1', 'blue');
r.style.setProperty('--clr-2', 'blue');
r.style.setProperty('--clr-3', 'blue');
r.style.setProperty('--clr-4', 'blue');
}