jquery LI的锚点悬停问题[JSFiddle inside]
请参阅 JSFiddle 以清楚地了解该问题 - http://jsfiddle.net/PeYYZ/
以上就是我想要的。当我将鼠标悬停在 li.parent 上时,ul.child 菜单会淡入,这很好。我希望子菜单保持打开状态,除非用户选择另一个 li.parent
。我尝试搞乱 mouseleave
,但我不认为这就是我想要的。
我需要的逻辑是:
如果用户将鼠标悬停在
li
上 类parent
,显示它的ul.child
如果用户将鼠标移动到其他位置 不是
li.parent
,ul.child
应保持打开状态。- 如果用户移动到另一个
li.parent
,那么该li.parent ul.child
应该打开,并且之前打开的应该打开 消失。
提前致谢
Please see the JSFiddle for a pretty clear idea of the problem - http://jsfiddle.net/PeYYZ/
The above sort of does what I want. When I hover over li.parent
, the ul.child
menu fades in, which is fine. I want the sub menu to remain open, unless the user selects another li.parent
. I tried messing with mouseleave
,but I don't think that's what I'm after.
The logic I need is:
if user hovers over a
li
with
classparent
, show it'sul.child
If the user then moves the mouse to somewhere else that
isn't ali.parent
, theul.child
should remain open.- if the user moves to another
li.parent
, then thatli.parent ul.child
should open, and the previously open one should
disappear.
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样? http://jsfiddle.net/nzFZ6/ 我也必须编辑 CSS 部分。
Like this? http://jsfiddle.net/nzFZ6/ I had to edit the CSS part too.
这是我的解决方案: http://jsfiddle.net/MFZ8Q/
关键是仅选择直接链接li.parent 的后代,然后确保它们可见。
希望这是您想要的:)
This is my solution: http://jsfiddle.net/MFZ8Q/
The key was selecting only links that are direct descendants of li.parent, then just making sure they are visible.
Hopefully this is what you wanted :)