Created
October 12, 2017 07:32
-
-
Save eightHundreds/6f9c2990ba4cbf6a93682ee4583060ed to your computer and use it in GitHub Desktop.
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
function hasClass( elements,cName ){ | |
return !!elements.className.match( new RegExp( "(\\s|^)" + cName + "(\\s|$)") ); | |
}; | |
function addClass( elements,cName ){ | |
if( !hasClass( elements,cName ) ){ | |
elements.className += " " + cName; | |
}; | |
}; | |
function removeClass( elements,cName ){ | |
if( hasClass( elements,cName ) ){ | |
elements.className = elements.className.replace( new RegExp( "(\\s|^)" + cName + "(\\s|$)" ), " " ); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment