Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Created November 15, 2016 08:19
Show Gist options
  • Save andreasvirkus/56daa855aecaf9b988cddb6d94e7fdcc to your computer and use it in GitHub Desktop.
Save andreasvirkus/56daa855aecaf9b988cddb6d94e7fdcc to your computer and use it in GitHub Desktop.
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