jQuery 激活具有多个链接的单个选项卡 - 同时在两个选项卡上设置活动类

发布于 11-01 17:25 字数 601 浏览 4 评论 0原文

正如标题所示,我想制作一个选项卡界面,其中有多个链接控制同一选项卡面板。

希望您在查看示例时能明白我的意思: http://jsfiddle.net/kimatg/EtVZW/2/

这里一切正常,这些链接都运行良好,但一个问题是“活动”类(在本例中 .current)一次只能在一个选项卡选择器容器中工作...

换句话说,我有 2 个标签演示中的菜单(.map.tabnav);当我点击div.tabnav中的Region 2时,相应的a标签获取类.current,但相应的div.map 中的 a 标记则不然。

如何使两个 div 同时获取 .current 类,而不是在选择另一个选项卡时获取?

哦,顺便说一句,我在示例中使用了 jQuery 工具,但如果需要像 jQuery UI 那样以不同的方式实现它也没关系。

as the title says, I want to make a tab interface where I have multiple links that control the same tab panel.

Hopefully you'll get what I mean when you look at the example:
http://jsfiddle.net/kimatg/EtVZW/2/

Here everything works just fine and the links all work well, but one problem is that the "active" class (in this case .current) will only work in one tab-selector-containers at a time...

In other words, I have 2 tab menus (.map and .tabnav) in the demo; when I click Region 2 in div.tabnav, the corresponding a tag gets class .current, but the corresponding a tag in div.map doesn't.

How can I make both divs get .current classes at the same time and not when another tab is selected?

Oh and by the way I used jQuery Tools in the example, but It's fine if there's a need to implement it a different way like jQuery UI.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

咿呀咿呀哟2024-11-08 17:25:24

我不熟悉 jQuery 工具,所以我使用了 UI。

这是小提琴: http://jsfiddle.net/jomanlk/XwpDK/4/

基本上,我使用索引来突出显示正确的链接

var $tabs = $('#tabs').tabs({
    select : function(event, ui) {
        var selected = $tabs.tabs('option', 'selected'); 
        $('a').removeClass('highlight');
        $('a').eq(ui.index).addClass('highlight');
    }
});

$('.map a:first').addClass('highlight');
$('.map a').click(function(){
    $tabs.tabs( "select" , $(this).index());
});

I'm not familiar with jQuery Tools so I used UI.

Here's the fiddle : http://jsfiddle.net/jomanlk/XwpDK/4/

Basically, I used the index to highlight the proper link

var $tabs = $('#tabs').tabs({
    select : function(event, ui) {
        var selected = $tabs.tabs('option', 'selected'); 
        $('a').removeClass('highlight');
        $('a').eq(ui.index).addClass('highlight');
    }
});

$('.map a:first').addClass('highlight');
$('.map a').click(function(){
    $tabs.tabs( "select" , $(this).index());
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文