Reputation: 4920
how do i check which tabs is active using jquery tabs?
Upvotes: 8
Views: 19915
Reputation: 81
var selectedTabIndex = 0;
jQuery("#tabContainer").tabs({
select: function(event, ui) {
selectedTabIndex = ui.index;
}
});
You can use selectedTabIndex in your app
Upvotes: 0
Reputation: 11
I'm using something like this:
$tabContainer.tabs({
activate: function (event, ui) {
if (ui.newPanel.is("#TabId")) {
// do sth here
}
}
});
Upvotes: 1
Reputation: 3687
I needed to get the active tab during the activate event. I was able to do this using the option active call.
$('#tabs').tabs({
activate: function (event, ui) {
var activeTabId = $(this).tabs('option', 'active');
}
});
Upvotes: 2
Reputation: 15630
Please try with Index
function getIndex(){
return $("ul li.ui-state-active").index();
}
It will returns the index of selected li or tab.
Upvotes: 12
Reputation: 31
Not too sure about this but I think jQuery dynamically assigns a class of 'ui-state-active'
Upvotes: 1