Created
April 11, 2014 14:22
Extend JS native class manipulation to add multiple CSS classes
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
DOMTokenList::addClasses = (input) -> | |
classValues = input.split ' ' | |
for className in classValues | |
this.add className | |
return | |
# usage | |
# element.classList.addClasses 'xpto1 xpto2' | |
DOMTokenList::removeClasses = (input) -> | |
classValues = input.split ' ' | |
for className in classValues | |
this.remove className | |
return | |
# usage | |
# element.classList.removeClasses 'xpto1 xpto2' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment