Skip to content

Instantly share code, notes, and snippets.

@dshaw
Created April 21, 2010 15:48
Show Gist options
  • Save dshaw/373993 to your computer and use it in GitHub Desktop.
Save dshaw/373993 to your computer and use it in GitHub Desktop.
// From @codepo8
// http://www.smashingmagazine.com/2010/04/20/seven-javascript-things-i-wish-i-knew-much-earlier-in-my-career/
// Take the list of class attributes on an element and add new class.
function addclass(elm,newclass){
var classes = elm.className.split(' ');
classes.push(newclass);
elm.className = classes.join(' ');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment