Created
October 17, 2013 19:23
-
-
Save wkronemeijer/7030727 to your computer and use it in GitHub Desktop.
jQuery replacement functions
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(element, class_name) { | |
return element.classList.contains(class_name); | |
} | |
function addClass(element, class_name) { | |
if (!hasClass(element, class_name)) { | |
element.classList.add(class_name) | |
}; | |
} | |
function removeClass(element, class_name) { | |
if (hasClass(element, class_name)) { | |
element.classList.remove(class_name) | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment