Revision: 2439
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 19, 2007 06:43 by 1man
Initial Code
function addClass(element, value) { if(!element.className) { element.className = value; } else { newClassName = element.className; newClassName+= " "; newClassName+= value; element.className = newClassName; } }
Initial URL
Initial Description
Function to look if an element has a class, if it doesn't simply add it to the element. If it does have a class add it to the class that is already there. Function expects 2 values, the element to add the class to, and the new class name (value).
Initial Title
addClass Function
Initial Tags
class, function
Initial Language
JavaScript