加载新页面时Jquery滑出底部顶部鼠标悬停菜单问题
我正在努力将菜单从 mootools 转换为 jquery。有多种原因导致我必须切换 js 框架,我在这里需要一些帮助,因为我对 jquery 很陌生。
首先是实时站点上的工作 mootools 版本: http://www.kieleconomcis.de
如您所见,菜单悬停时向上移动,显示子菜单,并在您单击链接并加载页面时保持不动。
现在我必须将其转换为jquery,我还希望能够单独控制每个菜单的高度,因此它a)看起来更像条形图,b)我可以放置4个子菜单: )
我尝试了一下,复制粘贴,尝试并出错,最后在这里得到了这个 fiddle 。
我的问题是 - 我猜 - 我有一个 $('div.nav_body').hide();
但我需要告诉它它必须忽略如果前面的元素有 id="visible"
,则会产生效果,
这里是一些代码,以便您可以看到我需要触发的内容:
<h4 id="visible">Über uns</h4>
<div id="nav2-body" class="nav_body">
感谢您的任何建议。
i'm struggling with converting a menu from mootools to jquery. there are various reasons why i have to switch the js framework and i need some help here because i quite new to jquery.
first the working mootools version on the live site: http://www.kieleconomcis.de
as you can see the menu moves up on hover, reveals the sub menu and stays up when you click a link and load the page.
now that i have to convert this into jquery i also want to be able to control the heigth of each menu individually, so it a) looks more like a bar graph and b) i can place 4 submenus :)
i played around, copy&pasted, tried&errored and ended up with this fiddle here.
my problem is - i guess - that i have a $('div.nav_body').hide();
but i need to tell it that it has to ignore the effect if the element before it has an id="visible"
here is some of the code so you can see what i need to trigger:
<h4 id="visible">Über uns</h4>
<div id="nav2-body" class="nav_body">
thanks for any adice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
:not()
和:has()
选择器有效:filter()
方法也有效:或者使用
。 not()
从要隐藏的项目中删除一个子菜单:我在你的小提琴中测试了所有三个子菜单。但我真的不能说我最喜欢哪一个。
Using the
:not()
and:has()
selector works:The
filter()
method works as well:Or use
.not()
to remove the one submenu from the to-be-hidden items:I tested all three in your fiddle. I can't really say which one I like best, though.
您可以检查它的父 h4 是否将其 id 设置为可见
You can check if it's parent h4 has it's id set to visible