Skip to content

Instantly share code, notes, and snippets.

@DigitalKrony
Created November 27, 2018 15:31
Show Gist options
  • Save DigitalKrony/e204e159e95330ec235ce5e83e8c11f8 to your computer and use it in GitHub Desktop.
Save DigitalKrony/e204e159e95330ec235ce5e83e8c11f8 to your computer and use it in GitHub Desktop.

Revisions

  1. DigitalKrony created this gist Nov 27, 2018.
    13 changes: 13 additions & 0 deletions obj-removeClass.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    Object.prototype.removeClass = function (string) {
    var classList = this.className.split(' ');
    var classesToRemove = string.split(' ');

    for (var toRemove of classesToRemove) {
    var index = classList.indexOf(toRemove);
    if(index !== -1) {
    classList.splice(index, 1);
    }
    }

    this.classList = classList.join(' ');
    };