jQuery 导航 - 需要帮助

发布于 2024-08-13 05:52:27 字数 617 浏览 2 评论 0原文

我正在开发一个具有相当大的手风琴式导航的 网站 (它不使用手风琴 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

友谊不毕业 2024-08-20 05:52:27

我会将子菜单动画放在一个函数中,因此要调用子菜单,您可以在 a href 上使用

onclick="showSubMenu('id')"

该函数将处理滑入。然后,一旦单击需要显示子菜单的页面,只需添加到您的页面很小

<script>document.ready(function() {showSubMenu('parent-id')});</script>

希望这会有所帮助。

C

I would put the submenu animation in a function, so to call the submenu in, you use on your a href

onclick="showSubMenu('id')"

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

<script>document.ready(function() {showSubMenu('parent-id')});</script>

Hope this helps.

C

十秒萌定你 2024-08-20 05:52:27

您可能需要将类动态地应用为变量或应用到它本身的元素上。例如,

var page = 'ul#menu3';

然后使用此变量来触发初始状态 例如,

$('#ul#menu3').show();

这需要在与下拉列表相关的所有其他 javascript 之前运行

You probably need to apply the class dynamically either as a variable or on the element it self. e.g.

var page = 'ul#menu3';

Then use this variable to trigger the initial state e.g.

$('#ul#menu3').show();

This would would need to run before all the other javascript relating to the dropdowns

心如狂蝶 2024-08-20 05:52:27

这就是我最终用来解决问题的方法:

$(function(){
$('#mainContentTabs').tabs();
$('#subContentTabBoxes').tabs();
$('.interior #subContent > ul > li > a.drop').click(function(){
$(this).parent().children('ul').toggle("slow");
     return false;
});

$(window).ready(function() {
$('li.products ul').show();
    $('li.technical ul').show();
    $('li.tips ul').show();
$('li.quicklinks ul').show();
});

谢谢。

This is what I ended up using to solve the problem:

$(function(){
$('#mainContentTabs').tabs();
$('#subContentTabBoxes').tabs();
$('.interior #subContent > ul > li > a.drop').click(function(){
$(this).parent().children('ul').toggle("slow");
     return false;
});

$(window).ready(function() {
$('li.products ul').show();
    $('li.technical ul').show();
    $('li.tips ul').show();
$('li.quicklinks ul').show();
});

Thanks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文