Skip to content

Instantly share code, notes, and snippets.

View tevko's full-sized avatar
🇺🇲

Tim tevko

🇺🇲
  • NY
View GitHub Profile
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"
);