-
-
Save devbyray/afba5ac1a7d6548132491910049b0b50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const button: HTMLButtonElement = document.querySelector(".color-switch"); | |
button.addEventListener("click", function() { | |
const body: HTMLBodyElement = document.querySelector("body"); | |
body.classList.toggle("darkmode"); | |
if (button) { | |
button.innerText = body.classList.contains("lightmode") ? "Dark" : "Light"; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment