Skip to content

Instantly share code, notes, and snippets.

@lmartins
Created April 11, 2014 14:22
Extend JS native class manipulation to add multiple CSS classes
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