Created
November 15, 2016 08:19
-
-
Save andreasvirkus/56daa855aecaf9b988cddb6d94e7fdcc to your computer and use it in GitHub Desktop.
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
function classList(el) { | |
var list = el.classList; | |
return { | |
toggle: function(c) { list.toggle(c); return this; }, | |
add: function(c) { list.add (c); return this; }, | |
remove: function(c) { list.remove(c); return this; } | |
}; | |
} | |
// And then chain away! | |
classList(el).remove('foo').add('bar').toggle('baz'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment