Created
May 10, 2012 04:43
-
-
Save hsquareweb/2651070 to your computer and use it in GitHub Desktop.
jQuery: Horizontal Drop Down Menu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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