Set active tab by clicking a link thats outside of

2020-07-23 05:16发布

Im using the jQuery UI Tabs: http://api.jqueryui.com/tabs/

How can I make a link on my page thats outside of the tabs, when clicked make a certain tab active? Thanks

5条回答
放荡不羁爱自由
2楼-- · 2020-07-23 05:26

In IE10 option 'active' not work. I use instead of 'active' option 'selected'.

$( ".selector" ).tabs( "option", "selected", <number of tab> );
查看更多
看我几分像从前
3楼-- · 2020-07-23 05:34

See http://api.jqueryui.com/tabs/#option-active

To get current active tab index:

var currentActive = $( ".selector" ).tabs( "option", "active" );

To set current active tab:

$( ".selector" ).tabs( "option", "active", <number of tab> );

For example:

$('a').click(function(){
         $( ".tabs" ).tabs( "option", "active", 2 );
});
查看更多
We Are One
4楼-- · 2020-07-23 05:42

Try this:

<li ....> 
     <a href="#tab-number">Tab Title</a>
</li> 

and them your url look like this: "[URL]#tab-number"

I hope help you.... Regards...

查看更多
来,给爷笑一个
5楼-- · 2020-07-23 05:43

Ive marked @Secator's answer as correct as I can see from the documentation hes right. However for some reason it didnt work for me so instead I 'manually' simulated a click on the tab:

        $("#myTrigger").click(function(e) {
              $("#id-of-normal-tab-link").click();
              e.preventDefault(); //prevent default behavior of the a#myTrigger 
        });
查看更多
对你真心纯属浪费
6楼-- · 2020-07-23 05:48
$( "#tabs" ).tabs({ active: tabNumber });

tabNumber starts with 0

查看更多
登录 后发表回答