默认菜单选项

时间:2010-03-11 20:09:23

标签: jquery menu tabs

如何在此处使此菜单默认为“关于”标签?

http://www.sohtanaka.com/web-design/examples/horizontal-subnav/

所以当你的鼠标悬停在它们中的任何一个上时,它在about标签上?

2 个答案:

答案 0 :(得分:1)

我会为此提供约<li>个课程,也许class="default",以便以后更改。然后,只需更改悬停功能即可:

$("ul#topnav li").unbind().hover(function() {
  $(this).css({ 'background' : '#1376c9 url(topnav_active.gif) repeat-x'})
         .find("span").show();
  $(this).siblings('li').css({ 'background' : 'none'}).find("span").hide();
} , function() {
  if($(this).hasClass('default')) return;
  $(this).css({ 'background' : 'none'})
         .find("span").hide();
  $(this).siblings('.default').mouseenter();
});

You can view a demo of it here,如果你想在页面最初加载时显示它,你可以这样做:

$("ul#topnav li.default").mouseenter();

我不确定你是如何在你的网站上使用它的,但我会将悬停样式放入.hover类,然后你可以这样做:

答案 1 :(得分:0)

这样的东西

$("ul#topnav li:nth-child(2)").find("span").show();

将从li获取第二个<ul id="nav">并显示其下方的范围块。