Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wadmiraal/7654596 to your computer and use it in GitHub Desktop.
Save wadmiraal/7654596 to your computer and use it in GitHub Desktop.
Delay dropped-down menu hide by a few milliseconds, instead of just relying on CSS :hover. **Change main selector.**
$(document).ready(function() {
$('#header-main-menu li').hover(function() {
// Stop the timer.
clearTimeout(this.sfTimer);
// Display child lists.
$('> ul', this).css({left: 'auto', display: 'block'})
// Immediately hide nephew lists.
.parent().siblings('li').children('ul').css({left: '-999em', display: 'none'})
}, function() {
// Start the timer.
var uls = $('> ul', this);
this.sfTimer = setTimeout(function() {
uls.css({left: '-999em', display: 'none'});
}, 400);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment