Created
October 3, 2012 05:42
-
-
Save snowman-repos/3825248 to your computer and use it in GitHub Desktop.
JavaScript: Element.classList
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
// Add a class to an element | |
myElement.classList.add("newClass"); | |
// Remove a class to an element | |
myElement.classList.remove("existingClass"); | |
// Check for existence | |
myElement.classList.contains("oneClass"); | |
// Toggle a class | |
myElement.classList.toggle("anotherClass"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment