Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Applying CSS styles with Javascript

I have an instance where I want to apply a style with javascript in
order to override css settings in the stylesheet. (I'm working with an existing css styled menu system trying to collapse unused portions of the tree).

the css settings are along the lines of:

#rootlevel ul ul a {display:none;}

And I want to override with this style

#rootlevel ul ul#selecteditem a {display:block}

but with javascript.

Can this be done? I'm familiar with

object.style.display = 'block';

but how do we get the cascading events in there? Or can I?
[631 byte] By [BriC] at [2007-11-11 8:11:11]
# 1 Re: Applying CSS styles with Javascript
I have a workaround. :) Using document.write to write out a...

<style>
#rootlevel ul ul#selecteditem a{display:block;}
</style>

However, I still wonder if you can encapsulate this 'properly' using javascript.
BriC at 2007-11-11 23:34:58 >