View Full Version : DD Accordion: How do I apply different CSS to the currently selected submenu item

03-19-2008, 06:23 PM
1) Script Title: DD Accordion

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu.htm

3) Describe problem:

I'd like to know how I can modify the accordion script so that I can use different CSS on the currently selected submenu item.


Menu A
submenu 1
submenu 2 (currently selected)
submenu 3

I want a different background color for submenu 2 but there is no support for that in current script code.

03-19-2008, 08:08 PM
Are your sub menus also part of the accordion menu? In other words, do they expand/ contact with the animation in place? If so, applying a specific CSS class to the selected sub menu is no different than applying a CSS class to the main accordion menu headers, since each level of your menus is a separate instance of accordion menu. See nested accordion menu here: http://www.dynamicdrive.com/forums/showthread.php?t=29611

03-19-2008, 09:51 PM
Sorry, I sort of used the wrong language to describe my problem. I should have said different CSS for current submenu item.

For example, in the above menu, if the user is currently on the Upload Photo page, then I want the Photo link between Video and Audio to have a different background color.

03-20-2008, 04:24 AM
Hmm there's no way to "automate" the selection of the sub menu item the user is currently on with Accordion Menu script. It's actually a separate issue. What you basically want to do is somehow give the selected sub menu the desired CSS classname:

<li><a href="#" class="selected">Photo</a></li>

How you go about doing this though, whether manually or automatically, depends entirely on you.