[JS/CSS] Hover menu

Caporegime
Joined
18 Oct 2002
Posts
29,493
Location
Back in East London
[JS/CSS] Hover/Drop menu

"meh" is all I can say about these PITA's..

I've got two simple JS functions:

Code:
function ShowHover(id) {
    var elem = document.getElementById(id);
    elem.style.display = 'block';
}
function HideHover(id) {
    var elem = document.getElementById(id);
    elem.style.display = 'none';
}
Then I have the menu block..
Code:
<div class="menu">
  <ul class="menu">
    <li class="menu">home</li>
    <li class="menu">about us</li>
    <li class="menu" onmouseover="ShowHover('hoverMenu')">products and services</li>
    <li class="menu">contact us</li>
  </ul>
</div>

<!-- the hover menu.. -->
<div id="hoverMenu" style="display: none;" onmouseout="HideHover('hoverMenu')">
  <ul class="hoverMenu">
    <li class="hoverMenu">insight</li>
    <li class="hoverMenu">research</li>
    <li class="hoverMenu">consultancy</li>
  </ul>
</div>
as you can see, the desired effect is for the <li> with "products and services" to display the hover menu upon mouseover, and then hide it again onmouseout of the actual hover menu. I've positioned the hoverMenu to be right below the item, but it hides again as soon as the cursor touches it..

Any pointers?

Ta.
 
Last edited:
Back
Top Bottom