Return to Snippet

Revision: 2659
at March 20, 2007 13:08 by Todd


Updated Code
object.className

/* Example: */
var someObjectsClass = this.className;

Revision: 2658
at March 20, 2007 13:07 by Todd


Initial Code
object.className

/* Example */

var someObjectsClass = this.className;

Initial URL
http://www.webmasterworld.com/javascript/3090396.htm

Initial Description
One notorious discrepancy between IE and Firefox (or other "good" browsers) is the way they access the class HTML attribute. While I've used more complicated solutions in the past, this simple solution doesn't require any browser detection or even a function to set the class attribute that is used. Click the URL above for an explanation of how it works (see the comment by "penders").

Initial Title
class and className

Initial Tags
class, ie

Initial Language
JavaScript