how do i check which tabs is active using jquery tabs?
how do i check which tabs is active using jquery tabs?
Asked Answered
Please try with Index
function getIndex(){
return $("ul li.ui-state-active").index();
}
It will returns the index of selected li or tab.
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');
}
});
Not too sure about this but I think jQuery dynamically assigns a class of 'ui-state-active'
i need to check it programmatically, so i can do actions related to that –
Wunder
var selected = $tabs.tabs('option', 'selected'); // => 0 –
Wunder
I'm using something like this:
$tabContainer.tabs({
activate: function (event, ui) {
if (ui.newPanel.is("#TabId")) {
// do sth here
}
}
});
var index = $("#tabs").tabs('option', 'selected');
The selected option is delayed by 1 click if you are accessing the value in the activate event. –
Shufu
var selectedTabIndex = 0;
jQuery("#tabContainer").tabs({
select: function(event, ui) {
selectedTabIndex = ui.index;
}
});
You can use selectedTabIndex in your app
© 2022 - 2024 — McMap. All rights reserved.
ui-state-active
to the active tab. See jqueryui.com/demos/tabs with Firebug to see how it works. – Snowdrop