Skip to content

Instantly share code, notes, and snippets.

@snowman-repos
Created February 6, 2014 08:20
Show Gist options
  • Save snowman-repos/8840212 to your computer and use it in GitHub Desktop.
Save snowman-repos/8840212 to your computer and use it in GitHub Desktop.
HTML5 classList API
if "classList" in document.documentElement
# do something
# Adding a class
element.classList.add "bar"
# Removing a class
element.classList.remove "foo"
# Checking if has a class
element.classList.contains "foo"
# Toggle a class
element.classList.toggle "active"
element = document.querySelector("#test")
element.classList.add "two"
element.classList.remove "four"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment