class and className


/ Published in: JavaScript
Save to your folder(s)

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").


Copy this code and paste it in your HTML
  1. object.className
  2.  
  3. /* Example: */
  4. var someObjectsClass = this.className;

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.