View Full Version : main menu colour change when a sub menu selected

11-19-2005, 08:31 AM
Hello all, i have a java script which i am using to expand a submenu when i click a main menu, i want to change the main menu color after the submenu is expanded how do i do it, could any one suggest me ....

the following is the code block
/////////////// Java Script ////////////

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')

function SwitchMenu(obj){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
el.style.display = "block";
el.style.display = "none";

/////////////////// Html Code /////////////

<div class="menutitle" onclick="SwitchMenu('sub1')"> <a href="romperindex.htm">Main menu</a></div>
<span class="submenu" id="sub1">
- <a href="submenu1.htm">submenu1</a><br>
- <a href="submenu2.htm">submenu2</a><br>
- <a href="submenu3.htm">submenu3</a><br>


Thanks in advance for your help ......

11-20-2005, 06:17 PM
There should be stylesheet included with that script.
Unfortunately I don't know which script you have posted.