Vertical menu expand toggle on mouseover


Author Message
CS

Posted: 1/26/2011
Quote message 

Hello,
I did make a small JavaScript to expand the vertical menu items, so that I can use my onClick event for a different action.

It can be used like
<li>
<a href="somehref" onmouseover="return expandOrCollapse(this)">
your text</a>
</li> etc....

function expandOrCollapse(menu){
var ul = menu.nextSibling;
while(ul.tagName != "UL") // Search for the next UL tag
{
ul = ul.nextSibling;
if ( ul == null )
return true;
}
if ( ul.style.display == "none"
|| ul.style.display == "" ) {
ul.style.display = "block";
}
else
ul.style.display = "none";
return false;
}