如何使用jquery选项卡检查哪些选项卡是活动的?

时间:2021-10-30 07:15:30

how do i check which tabs is active using jquery tabs?

如何使用jquery选项卡检查哪些选项卡是活动的?

6 个解决方案

#1


10  

Please try with Index

请尝试与指数

 function getIndex(){
     return $("ul li.ui-state-active").index();
    }

It will returns the index of selected li or tab.

它将返回所选li或tab的索引。

#2


2  

I needed to get the active tab during the activate event. I was able to do this using the option active call.

我需要在激活事件期间获得活动选项卡。我可以使用active call选项来实现这一点。

$('#tabs').tabs({
    activate: function (event, ui) {
        var activeTabId = $(this).tabs('option', 'active');
    }
});

#3


1  

Not too sure about this but I think jQuery dynamically assigns a class of 'ui-state-active'

对此我不太确定,但我认为jQuery动态地分配了一个“ui-state-active”类

#4


0  

var index = $("#tabs").tabs('option', 'selected');

#5


0  

I'm using something like this:

我用的是这样的东西:

$tabContainer.tabs({
    activate: function (event, ui) {
        if (ui.newPanel.is("#TabId")) {
            // do sth here
        }
    }
});

#6


0  

var selectedTabIndex = 0;
jQuery("#tabContainer").tabs({
 select: function(event, ui) { 
  selectedTabIndex = ui.index; 
 }
});

You can use selectedTabIndex in your app

您可以在应用程序中使用selectedTabIndex

#1


10  

Please try with Index

请尝试与指数

 function getIndex(){
     return $("ul li.ui-state-active").index();
    }

It will returns the index of selected li or tab.

它将返回所选li或tab的索引。

#2


2  

I needed to get the active tab during the activate event. I was able to do this using the option active call.

我需要在激活事件期间获得活动选项卡。我可以使用active call选项来实现这一点。

$('#tabs').tabs({
    activate: function (event, ui) {
        var activeTabId = $(this).tabs('option', 'active');
    }
});

#3


1  

Not too sure about this but I think jQuery dynamically assigns a class of 'ui-state-active'

对此我不太确定,但我认为jQuery动态地分配了一个“ui-state-active”类

#4


0  

var index = $("#tabs").tabs('option', 'selected');

#5


0  

I'm using something like this:

我用的是这样的东西:

$tabContainer.tabs({
    activate: function (event, ui) {
        if (ui.newPanel.is("#TabId")) {
            // do sth here
        }
    }
});

#6


0  

var selectedTabIndex = 0;
jQuery("#tabContainer").tabs({
 select: function(event, ui) { 
  selectedTabIndex = ui.index; 
 }
});

You can use selectedTabIndex in your app

您可以在应用程序中使用selectedTabIndex