Make the slideUp
function inside of a setTimeout
so that inside of the submenu you can clear the timeout (and stop the slideUp
) if it is hovered over. If you want to allow more time for the user to get to the submenu before it disappears, just change the 250
in the second from last line. This is amount of time in milliseconds. At this point all you would have to do is position the submenu accordingly to the menu.
Here is a really rough DEMO
var t;
$('.p_over, .submenu').on('mouseenter', function(){
if(t){
clearTimeout(t);
t = false;
}
$('.submenu').slideDown(50);
}).on('mouseleave', function(){
t = setTimeout(function(){
$('.submenu').slideUp(50);
}, 250);
});