Created
January 27, 2014 10:07
-
-
Save jjmu15/8646069 to your computer and use it in GitHub Desktop.
Remove specified class - vanilla JS
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
// removeClass, takes two params: element and classname | |
function removeClass(el, cls) { | |
var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)"); | |
el.className = el.className.replace(reg, " ").replace(/(^\s*)|(\s*$)/g,""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What do you think about this