In answer to WebmasterWorld.com JavaScript Forum:
http://www.webmasterworld.com/javascript/3073901.htm

It is reasonably common/traditional for people to change the style of a particular element in the onmouseover event of that element. But what if you want to change the style of all elements that are of a particular class? You could step through the DOM tree and change all elements that have a particular class set. Or it maybe better to change the class to a different class entirely, that way you can keep all the presentation in the CSS file and away from the JavaScript - you still have to step through the DOM tree though.

But what about changing the style of an actual class? Ok, this may move some of the presentation back into the JavaScript, but it would save traversing the DOM. Hhhmmmm...

The following is an ordered list with several li elements of a class of "test".

  1. This element has a class of 'test'.
  2. This element has a class of 'test' as well.
  3. This a normal element with no class.
  4. This too is an element with a class of 'test'.
  5. This a normal element with no class.
  6. This is an element with a class of 'test' too.

[Change a style of the class 'test'] [Change it back]

This simple example seems to work ok in FF1.5 and IE6, but not Opera8! Opera8 does not support the styleSheets array. There are many cross-browser problems that make this method almost impossible to implement! The most important being that the rules[] array varies in nearly every browser!!

[Home]