Skip to content

Instantly share code, notes, and snippets.

@snowman-repos
Created October 3, 2012 05:42
Show Gist options
  • Save snowman-repos/3825248 to your computer and use it in GitHub Desktop.
Save snowman-repos/3825248 to your computer and use it in GitHub Desktop.
JavaScript: Element.classList
// 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