Created
February 6, 2014 08:20
-
-
Save snowman-repos/8840212 to your computer and use it in GitHub Desktop.
HTML5 classList API
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
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