在Jquery-UI选项卡中按名称切换到选定的选项卡 [英] Switch to selected tab by name in Jquery-UI Tabs

查看:134
本文介绍了在Jquery-UI选项卡中按名称切换到选定的选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有三个标签:

<div id="tabs">
    <ul>
        <li><a href="#sample-tab-1"><span>One</span></a></li>
        <li><a href="#sample-tab-2"><span>Two</span></a></li>
        <li><a href="#sample-tab-3"><span>Three</span></a></li>
    </ul>
</div>

我想用它的名字交换到#sample-tab-2.我知道我可以切换到选项卡,如果我知道它的编号,但是如果遇到了这种情况,我将不知道.

I would like to swap to #sample-tab-2 by it's name. I know I can switch to a tab if I know it's number, but in the case I've run into I won't know that.

注意:JQuery 1.3.1/JQuery-UI 1.6rc6

Notes: JQuery 1.3.1 / JQuery-UI 1.6rc6

推荐答案

我无法获得上一个答案.我执行了以下操作以按名称获取选项卡的索引:

I could not get the previous answer to work. I did the following to get the index of the tab by name:

var index = $('#tabs a[href="#simple-tab-2"]').parent().index();
$('#tabs').tabs('select', index);

这篇关于在Jquery-UI选项卡中按名称切换到选定的选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆