Pawe³ wrote:
> Is there any way I can dynamically (taking advantage of
> JavaScript) change the properties for classes defined in
> CSS styles??
On dynamic visual browsers supporting the - document.styleSheets -
object (either in the Microsoft proprietary form or the W3C standard
form), yes.
> Let say there's a CSS class ".regtex"
Class selectors introduce some potentially unexpected issues as the -
selectorText - may be a normalised equivalent such as
"*[class~=regtext]" rather than the more expected, original -
selectorText - ".regtex", so some extra effort (indexOf or regular
expression) may be necessary to identify the correct cssRule.
> and it forces the browser to
> display all elements of that class in red.
Browsers cannot be forced to do anything, you just get to offer a
suggestion of color that they may (but mostly will) follow.
> Now I want to change this class so all elements
> belonging to this class are displayed in blue,
> however I don't want to change every single element, I
> just want to change the class' properties.
Assigning alternative values to the properties of the class's rule in
the style sheet object in the stylesheets collection will alter the CSS
acting on a page, in dynamic vi9sual browsers supporting the -
document.styleSheets - collection. Other factors may override the actual
presentation to the user.
> Is it possible??
Possible but not certain.
Richard.
Pawel wrote:
> Is there any way I can dynamically (taking advantage of JavaScript) change
> the properties for classes defined in CSS styles??
[quoted text clipped - 3 lines]
> want to change every single element, I just want to change the class'
> properties. Is it possible??
One can access a collection of the style rules within a style sheet with
"cssRules" in order to alter any of its properties. Say your stylesheet
looked like this:
<style type="text/css">
a {color:green;}
.regtex {color:red;}
</style>
Then one can alter anchors to orange with:
document.stylesheets[0].cssRules[0].style.color. = "orange"
And one can alter regtex classed elements to blue with:
document.stylesheets[0].cssRules[1].style.color. = "blue"
You may also wish to look into "selectorText" which is a string
containing the value of the selector, where in your case, selectorText
will contain ".regtex".
Another way is to call another class which will override previous
declarations. Here is an example which changes classes onmouseover:
http://www.home.golden.net/~richterf/Opera/ChangeClass_4_Opera_1.html
Disregard the fixed box which describes an Opera redraw bug.

Signature
Gus