简体   繁体   English

我使用hover()断开的jQuery下拉菜单

[英]My broken jQuery slide down menu using hover()

I have an html link that has uses hover() (well, the hoverIntent plugin...but same difference) to trigger a div to slidedown (I animate the CSS top attribute). 我有一个HTML链接,该链接使用hover()(好吧,hoverIntent插件...但相同)来触发div向下滑动(我为CSS top属性设置了动画)。

This all works and looks perfectly, except that when the mouse moves off of the hyperlink and onto the div that contains the menu links, it immediately triggers the mouseleave event and the menu vanishes. 所有这些都可以正常工作,并且看起来很完美,除了当鼠标从超链接移到包含菜单链接的div上时,它立即触发mouseleave事件,并且菜单消失。

Obviously, I felt kind of stupid after tweaking it endlessly before noticing this "bug". 显然,在注意到这个“ bug”之前,不断地对其进行调整之后,我感到有些愚蠢。

The problem is: I can't really figure out a way to achieve the effect I want. 问题是:我无法真正找到实现所需效果的方法。

Here is a link to my work: http://clifgriffin.com/blockade 这是我工作的链接: http : //clifgriffin.com/blockade

How would you, oh experts, accomplish what I'm trying to do? 专家,您将如何完成我要尝试的工作?

I tried to separate the mouse enter and mouse leave functions...adding the former to the link and the latter to the div, but this doesn't work quite right, and even if I solved that quirk, it wouldn't trigger mouse leave properly when you hover the link and then move up. 我试图分离出鼠标进入和鼠标离开功能...将前者添加到链接中,将后者添加到div中,但这不能正常工作,即使我解决了这个问题,也不会触发鼠标当您将链接悬停然后向上移动时,请正确离开。

Basically, as long as moving the mouse from the link to the menu doesn't trigger mouseleave, I'd be fine. 基本上,只要将鼠标从链接移动到菜单不会触发mouseleave,就可以了。

I really do not want to set a boolean for each menu, and setup a bunch of events on every element surrounding the menus to trigger certain actions. 我真的不想为每个菜单设置一个布尔值,并在菜单周围的每个元素上设置一堆事件来触发某些动作。 This has to be simpler than that. 这必须比这更简单。

Any ideas? 有任何想法吗?

Thanks in advance, Clif 预先感谢Clif

try this: 尝试这个:

var accoIn = function(){
 topSlideIn($("#top_menu_slideout .aco"));
 $("#top_menu_links .accommodations").unbind("mouseover");      
};

$("#top_menu_links .accommodations").hoverIntent(accoIn,function(){});

$("#top_menu_slideout .aco").hoverIntent(function(){},function(){
 topSlideOut($("#top_menu_slideout .aco"));     
 $("#top_menu_links .accommodations").hoverIntent(accoIn,function(){});
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM