Skip to content

Instantly share code, notes, and snippets.

@yellowberri-snippets
Created September 24, 2013 17:35
Show Gist options
  • Save yellowberri-snippets/6688391 to your computer and use it in GitHub Desktop.
Save yellowberri-snippets/6688391 to your computer and use it in GitHub Desktop.
JS: Class Swap Function
function classSwap(classOne, classTwo, target) {
if ( $(target).hasClass(classOne) ) {
$(target).removeClass(classOne).addClass(classTwo);
}
else if ( $(target).hasClass(classTwo) ) {
$(target).removeClass(classTwo).addClass(classOne);
}
else {
$(target).addClass(classOne);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment