Skip to content

Instantly share code, notes, and snippets.

@dandean
Created January 29, 2010 07:28
Show Gist options
  • Select an option

  • Save dandean/289525 to your computer and use it in GitHub Desktop.

Select an option

Save dandean/289525 to your computer and use it in GitHub Desktop.
Element.addMethods({
/**
* Element extension to swap out one class for another on an element.
**/
swapClassName: function(element, oldClassName, newClassName) {
if (!(element = $(element))) return;
return element.removeClassName(oldClassName).addClassName(newClassName);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment