Created
April 21, 2010 15:48
-
-
Save dshaw/373993 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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