Hey there stack overflow crew,
Quick question that always seems to come up when building custom drop down navigation systems using jquery. Now the ideal scenario for drop down menus would be to have the parent and children in
Let's say you have a DIV containing your primary navigation items and another below containing your child menus.
When you rollover the parent the child menu appears however when these are seperate 's the rollout state get's tricky. So I nested the hovers to try and get around this and it alllmost works.
$("div.primary-nav").mouseenter(function () {
clearTimeout($(this).data('timeoutId'));
$("div.doormat-nav-wrapper").slideDown("slow");
}).mouseleave(function () {
$("div.doormat-nav-wrapper").mouseenter(function () {
clearTimeout($(this).data('timeoutId'));
$("div.doormat-nav-wrapper").slideDown("slow");
}).mouseleave(function () {
var someelement = this;
var timeoutId = setTimeout(function(){
$("div.doormat-nav-wrapper").slideUp("slow");
$(someelement).data('timeoutId', timeoutId); //set the timeoutId, allowing us to clear this trigger if the mouse comes back over
});
});
});
Logically what I'm trying to achieve is
When the user rolls over the div.primary-nav .... div.doormat-nav-wrapper shows... when rolling off the primary nav div.doormat-nav-wrapper hides UNLESS div.doormat-nav-wrapper itself is being hovered on.
Any feedback or suggestions would be greatly appreciated. THANKS!