Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could do this:</p> <pre><code>$('#head_navigation li a').hover(function(){ // Hide the visible subnavigations $('#head_subnavigation ul:visible').css('display','none'); // Show the appropriate subnavigation $('#head_subnavigation ul#' + $(this).attr('title')).css('display','block'); }); </code></pre> <p>That way the currently visible #head_subnavigation ul's are hidden when you mouse over a new top level navigation li. You should wrap the whole navigation in a div to handle the mouseout event when a user leaves the menu area completely.</p> <pre><code>$('#navigationDiv').mouseout(function(){ $('#head_subnavigation ul:visible').css('display','none'); }); </code></pre> <p>The problem with having a wrapping div is that if the menu extends beyond the div, the mouseout event will fire thus hiding your menu. There is another approach you could take...</p> <pre><code>// Globals var menuHoverTimer = 0; var menuHoverTimerLimit = 3; // 3 seconds var menuHoverTimerIntervalID; function stopHoverTimer(){ clearInterval(menuHoverTimerIntervalID); } function resumeHoverTimer(){ // This will run the menuHoverHandler function every 1 second menuHoverTimerIntervalID = setInterval(menuHoverHandler, 1000); } function menuHoverHandler(){ menuHoverTimer++; if(menuHoverTimer &gt; menuHoverTimerLimit) { stopHoverTimer(); $('#head_subnavigation ul:visible').css('display','none'); menuHoverTimer = 0; } } </code></pre> <p>Then in each of your hover actions, on mouse over run stopHoverTimer() and on mouse out run resumeHoverTimer(); The way I have that setup, it will hide the menus after 3 seconds of the user not mousing over the menu. I think you may want that to be shorter.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload