Created
March 28, 2021 04:31
-
-
Save tevko/5ccd2fd623eeba20aef86540e0c3669f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 toggle = document.querySelectorAll(".switch input"); | |
toggle.forEach((el) => | |
el.addEventListener("click", (e) => { | |
const isPressed = el.getAttribute("aria-pressed"); | |
el.setAttribute( | |
"aria-pressed", | |
// this part is tricky for humans cause "false" === true, since a non empty string is truthy in js | |
isPressed === "false" ? "true" : "false" | |
); | |
}) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment