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 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" | |
); |
OlderNewer