Skip to content

Instantly share code, notes, and snippets.

@wkronemeijer
Created October 17, 2013 19:23
Show Gist options
  • Save wkronemeijer/7030727 to your computer and use it in GitHub Desktop.
Save wkronemeijer/7030727 to your computer and use it in GitHub Desktop.
jQuery replacement functions
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