简体   繁体   English

多级jQuery标签:二级链接未打开关联的标签部分

[英]Multi-level jQuery tabs: secondary level links not opening associated tab section

I'm trying to put together a multi-level jQuery tabbed navigation system on a page. 我正在尝试在页面上组合多级jQuery选项卡式导航系统。

ie Link 1 | 即链接1 | Link 2 连结2

If you hover over 'Link 2', the following would display: 如果将鼠标悬停在“链接2”上,则会显示以下内容:

Link 1 | 链接1 | Link 2 Link 2's Link 1 | 链接2链接2的链接1 | Link 2's Link 2 链接2的链接2

Clicking on either 'Link 2's Link 1' or 'Link 2's Link 2' will take you to that tabbed section of the page; 单击“链接2的链接1”或“链接2的链接2”将带您到页面的选项卡式部分; please note this doesn't result in a new page request, as the content of either of those links were previously hidden as the currently selected tab is 'Link 1', and so just become visible at this point. 请注意,这不会导致新的页面请求,因为这些链接中的任何一个链接的内容先前都已隐藏,因为当前选中的标签为“链接1”,因此此时才可见。

The code is the following (note: streamlined for brevity): 代码如下(注:为简洁起见):

<span id="form" class="tabs">
<div>        
 <ul>            
 <li><a href="#blog">Blog</a></li>            
 <li><a href="#links">Links</a>
   <ul id="links-tabs-list">                             
   <li><a href="#links_add">Add</a></li>
   <li><a href="#links_manage">Manage</a></li>
   </ul>
  </li>
  <li><a href="#images">Images</a></li>
  <li><a href="#more">More..</a></li>
 </ul>
</div>

<div id="blog"> // content goes here..  </div>
<div id="links">
    <div id="links_add"> // content goes here </div>
    <div id="links_manage"> // content goes here </div>           
 </div>
 <div id="images">  // content goes here.. </div>
 <div id="more"> // content goes here.. </div>
</span>

The jQuery tabs are set using, $('.tabs').tabs(), and working fine. 使用$('。tabs')。tabs()设置jQuery选项卡,并且工作正常。 Additionally, the CSS is also working correctly with 'Add' and 'Manage' links for the 'Links' section displaying only when 'Links' is hovered. 此外,CSS也可以正常工作,并且“链接”部分的“添加”和“管理”链接仅在悬停“链接”时显示。 However, when it is hovered, clicking on either 'Add' or 'Manage' doesn't show the 'links_add' or 'links_manage' id divs. 但是,将鼠标悬停时,单击“添加”或“管理”不会显示“ links_add”或“ links_manage” ID div。 Clicking on any other top-level tab link (such as 'Images' or 'More'), however, results in the correct tabbed section being displayed. 但是,单击任何其他顶级选项卡链接(例如“图像”或“更多”),将显示正确的选项卡式部分。 Hoping someone can let me know what I need to do in order to get clicking on any of the secondary tab level links to result in the associated tab content section to open. 希望有人能让我知道我需要做什么,才能单击任何辅助标签级别的链接,以打开相关的标签内容部分。

Hope I've been clear! 希望我已经清楚了! Any help is much appreciated. 任何帮助深表感谢。

UPDATE 更新

Sorry guys for assuming the CSS isn't needed to investigate a solution. 抱歉,假设不需要CSS来研究解决方案。 Here it is for the tabs, keeping in mind I'm aware (and not currently bothered) with the on-hover location of the second tab level): 这里是用于选项卡的,请记住,我知道(并且当前不打扰)第二个选项卡级别的悬停位置):

.tabs ul { list-style-type: none; padding-left: 0; width: 100%; }
.tabs ul li { display: inline; }
.tabs ul li.final { margin-right: 0px; }
.tabs .ui-tabs-selected a, .tabs .ui-tabs-selected a:hover { cursor: text; text-decoration: none; }
.tabs ul li, .tabs ul li a { color: #DEDEDE; margin-right: 8px; }
.tabs ul li a { text-decoration: none; }
.tabs ul li a:hover { color: #e07979; }
.tabs .ui-tabs-selected a, .tabs .ui-tabs-selected a:hover{ color: #C24B4B; }
.tabs ul li ul { display: none; }
.tabs ul li:hover ul, .tabs ul li.hover ul { position: absolute; display: inline; left: 0; width: 100%; margin: 0; padding: 0; }
.tabs ul li:hover li, .tabs ul li.hover li { float: left; }
.tabs ul  li:hover li a, .tabs ul  li.hover li a { color: #000; }
.tabs ul  li li a:hover { color: #357; }
.ui-tabs-hide { display: none; }

As for the JS, I'm not using a custom jQuery tabs implementation, and so the only (relevant) JS I'm using is: 至于JS,我没有使用自定义的jQuery选项卡实现,因此,我正在使用的唯一(相关)JS是:

$(function (){

   $('.tabs').tabs();$('.tabs').tabs();

});

If there's anything else needed, please let me know and apologies in advance if there is! 如果还有其他需要,请事先通知我,如有歉意!

You're doing it wrong! 你这样做是错的! multilevel tabs are not directly supported by jquery, here is the trick: jQuery不直接支持多级选项卡,这是窍门:

<span id="form" class="tabs">
<div>        
 <ul>            
 <li><a href="#blog">Blog</a></li>            
 <li><a href="#links">Links</a>   
  </li>
  <li><a href="#images">Images</a></li>
  <li><a href="#more">More..</a></li>
 </ul>
</div>

<div id="blog"> // content goes here..  </div>
<div id="links" class="tabs">
    <ul id="links-tabs-list">                             
   <li><a href="#links_add">Add</a></li>
   <li><a href="#links_manage">Manage</a></li>
   </ul>
    <div id="links_add"> // content goes here </div>
    <div id="links_manage"> // content goes here </div>           
 </div>
 <div id="images">  // content goes here.. </div>
 <div id="more"> // content goes here.. </div>
</span>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM