Skip to content

Instantly share code, notes, and snippets.

@Geruhn
Created November 25, 2013 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Geruhn/7644631 to your computer and use it in GitHub Desktop.
Save Geruhn/7644631 to your computer and use it in GitHub Desktop.
JavaScript: (add|remove|toggle)Many
DOMTokenList.prototype.addMany = function(classes) {
var classes = classes.split(' ');
for (var i = classes.length - 1; i >= 0; i--) {
this.add(classes[i]);
};
};
DOMTokenList.prototype.removeMany = function(classes) {
var classes = classes.split(' ');
for (var i = classes.length - 1; i >= 0; i--) {
this.remove(classes[i]);
};
};
DOMTokenList.prototype.toggleMany = function(classes) {
var classes = classes.split(' ');
for (var i = classes.length - 1; i >= 0; i--) {
this.toggle(classes[i]);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment