Created
May 1, 2020 07:05
-
-
Save rsschouwenaar/771b2016a24e333b07d01ff9b79586fe 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("lightmode"); | |
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