鼠标悬停时的 jQuery 悬停问题
我使用 jQuery 变量“mouseover”和“mouseout”在悬停在另一个 DIV 元素上时显示 DIV 元素。
http://74.54.17.66/~adbuynet/case-studies/ - 如果您将鼠标悬停在在右上角的“号召性用语”上,您会看到一个下拉菜单。
问题是,当鼠标悬停在下拉菜单本身上时,下拉菜单开始表现得很奇怪并且不会保持打开状态。我的 jQuery 代码是:
$("#call-to-action").mouseover(function(e) {
$("#call-to-action-dropdown").show("slide", { direction: "up" }, 200);
e.stopPropagation();
});
$("#call-to-action").mouseout(function(e) {
$("#call-to-action-dropdown").hide("slide", { direction: "up" }, 200);
});
});
请问我犯了什么错误?
I am using the jQuery variable "mouseover" and "mouseout" to show a DIV element when hovering over another.
http://74.54.17.66/~adbuynet/case-studies/ - If you hover over "Call to Action" in the top right, you see a dropdown.
The problem is, that when mousing over the dropdown itself, the dropdown starts acting funky and does not stay open. My jQuery code is:
$("#call-to-action").mouseover(function(e) {
$("#call-to-action-dropdown").show("slide", { direction: "up" }, 200);
e.stopPropagation();
});
$("#call-to-action").mouseout(function(e) {
$("#call-to-action-dropdown").hide("slide", { direction: "up" }, 200);
});
});
What mistake have I made please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
mouseenter
和mouseleave
而不是mouseover
和mouseout
。请参阅http://api.jquery.com/mouseenter/。(您几乎永远不想使用
mouseover
/mouseout
,当您这样做时,您就会知道。)Use
mouseenter
andmouseleave
instead ofmouseover
andmouseout
. See http://api.jquery.com/mouseenter/.(You’ll almost never want to use
mouseover
/mouseout
, and when you do, you’ll know it.)