jQuery 导航 - 需要帮助
我正在开发一个具有相当大的手风琴式导航的 网站 (它不使用手风琴 UI)。
有四个子菜单部分,单击时会打开。我突出显示了活动链接。剩下的一个步骤是在子菜单内的页面上时保持当前活动子菜单打开。当我使用静态页面时,我可以保持它打开,但在这个网站上,导航是一个包含文件,因此我需要一些帮助来制定一种动态方式来保持这些部分打开。
这是我正在使用的代码:
<script type="text/javascript">
$(function(){
$('ul#menu3 ul').hide();
$('ul#menu3 > li > a.drop').click(function(){
$(this).parent().children('ul').toggle("slow");
return false;
});
});
</script>
基本上我需要的是某种方法将类应用到活动组以便它显示。任何帮助将不胜感激。
谢谢。
I am working on a site with a fairly large accordion style navigation (it does not use the accordion UI).
There are four sub-menu sections that toggle open when clicked. I have the active link highlighted. The one remaining step is to keep the current active sub-menu open when on a page within the sub-menu. I can keep it open when I am working with static pages, but on this site the navigation is an includes file and therefore I need some help working out a dynamic way to keep those sections open.
Here is the code I am using:
<script type="text/javascript">
$(function(){
$('ul#menu3 ul').hide();
$('ul#menu3 > li > a.drop').click(function(){
$(this).parent().children('ul').toggle("slow");
return false;
});
});
</script>
Basically what I need is some way to apply a class to the active group so that it will show. Any help would be greatly appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会将子菜单动画放在一个函数中,因此要调用子菜单,您可以在 a href 上使用
该函数将处理滑入。然后,一旦单击需要显示子菜单的页面,只需添加到您的页面很小
希望这会有所帮助。
C
I would put the submenu animation in a function, so to call the submenu in, you use on your a href
That function would handle the sliding in. Then once clicked onto a page that requires a submenu to appear, simply add to the end of your page a small
Hope this helps.
C
您可能需要将类动态地应用为变量或应用到它本身的元素上。例如,
然后使用此变量来触发初始状态 例如,
这需要在与下拉列表相关的所有其他 javascript 之前运行
You probably need to apply the class dynamically either as a variable or on the element it self. e.g.
Then use this variable to trigger the initial state e.g.
This would would need to run before all the other javascript relating to the dropdowns
这就是我最终用来解决问题的方法:
谢谢。
This is what I ended up using to solve the problem:
Thanks.