Skip to content

Instantly share code, notes, and snippets.

@betojsx
Last active December 4, 2017 02:36
Show Gist options
  • Save betojsx/9a04a5e64907fc6e1471448d5c59692c to your computer and use it in GitHub Desktop.
Save betojsx/9a04a5e64907fc6e1471448d5c59692c to your computer and use it in GitHub Desktop.
Remove Classes if have Prefix / Match your String Vanilla JavaScript
var prefix = "prefix";
var classes = el.className.split(" ").filter(function(c) {
return c.lastIndexOf(prefix, 0) !== 0;
});
el.className = classes.join(" ").trim();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment