Quiero que al pulsar el botón de la parte superior izquierda se cambie el color de lá página todas las veces que le de al botón pero en cambio cuando le doy 2 veces ya no me deja cambiar mas de color alguna solución? Estoy usando JS
// Colors
let defaultColor = "linear-gradient(to right, #000000 , #000000 ,#0044ff)"; // Color of the page
let lightBgColor = "linear-gradient(to right, rgb(229, 229, 229), rgb(0, 68, 255), #04f)";
const thmBtn = document.getElementById("changeThemeButton");
thmBtn.addEventListener("click", () => {
// Elements that change
let bg = document.body;
// Change to light color
if (bg.style.background === "" || bg.style.background === defaultColor) {
bg.style.background = lightBgColor;
} else {
bg.style.background = defaultColor;
}
})
body {
background: linear-gradient(to right, #000000, #000000, #0044ff);
margin: 0;
}
#changeThemeButton {
font-size: 1em;
border-radius: 50%;
cursor: pointer;
}
<body>
<button id="changeThemeButton">
<i class="fas fa-adjust"></i>
</button>
</body>