Skip to content

Instantly share code, notes, and snippets.

@hsquareweb
Created May 10, 2012 04:43
Show Gist options
  • Save hsquareweb/2651070 to your computer and use it in GitHub Desktop.
Save hsquareweb/2651070 to your computer and use it in GitHub Desktop.
jQuery: Horizontal Drop Down Menu
// HORIZONTAL DROP DOWN MENU
var timeout = 3000;
var closetimer = 0;
var navitem = 0;
function nav_open(){
nav_canceltimer();
nav_close();
navitem = $(this).find('ul').css('visibility', 'visible');
}
function nav_close(){
if(navitem) navitem.css('visibility', 'hidden');
}
function nav_timer(){
closetimer = window.setTimeout(nav_close, timeout);
}
function nav_canceltimer(){
if(closetimer){
window.clearTimeout(closetimer);
closetimer = null;
}
}
$('#nav > li').bind('mouseover', nav_open);
$('#nav > li').bind('mouseout', nav_timer);
document.onclick = nav_close;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment