DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Applying CSS styles with Javascript

  1. #1
    Join Date
    Mar 2006
    Posts
    2

    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?

  2. #2
    Join Date
    Mar 2006
    Posts
    2
    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.

Similar Threads

  1. Replies: 5
    Last Post: 05-06-2006, 10:22 PM
  2. problems with javascript
    By Michael in forum ASP.NET
    Replies: 10
    Last Post: 11-08-2005, 01:19 PM
  3. Javascript Flash CSS
    By chrisz in forum Web
    Replies: 0
    Last Post: 10-25-2005, 07:07 PM
  4. JavaScript and the new Netscape 6 Browser
    By Greg Rothlander in forum ASP.NET
    Replies: 0
    Last Post: 11-05-2001, 03:25 PM
  5. Sample Sites.
    By Murray Foxcroft in forum Web
    Replies: 5
    Last Post: 11-02-2000, 03:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center