I have a menu script:
[CODE]
function hideSub() {
if (!document.getElementsByTagName)
return;
var mnu = document.getElementById(“menu”);
var toplis = mnu.getElementsByTagName(“li”);
for (it = 0; it < toplis.length; it++) { /* each top li */
if (toplis[it].className != ‘show’) {
var sublis = toplis[it].getElementsByTagName(“li”);
for (is = 0; is < sublis.length; is++) { /* each sub li */
if (sublis[is].style)
sublis[is].style.display = ‘none’;
}
}
}
}
function mShow(Me) {
if (!Me.getElementsByTagName)
return;
hideSub();
var mylis = Me.getElementsByTagName(“li”);
for (j = 0; j < mylis.length; j++) {
mylis[j].style.display = ‘block’;
}
}
Right now, when a top level item is clicked, it opens the menu but does not close when re-clicked. Opening another menu item will close it but I want to be able to close the open one. The menu is called like this:
[CODE]
<ul id=”menu”>
<li onclick=”mShow(this);return false;”>Options 1
<ul>
<li><a href=”#”>Item 1</a></li>
<li><a href=”#”>Item 1</a></li>
<li><a href=”#”>Item 1</a></li>
<li><a href=”#”>Item 1</a></li>
</ul>
</li>
</ul>
Any ideas? (I don’t have it online so I can give a URL. If you need the CSS or entire HTML portion of the script, let me know.)