Last active
December 4, 2017 02:36
-
-
Save betojsx/9a04a5e64907fc6e1471448d5c59692c to your computer and use it in GitHub Desktop.
Remove Classes if have Prefix / Match your String Vanilla JavaScript
This file contains 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
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