how do i check which tabs is active using jquery tabs?
how do i check which tabs is active u开发者_如何学编程sing jquery tabs?
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'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');
var selectedTabIndex = 0;
jQuery("#tabContainer").tabs({
select: function(event, ui) {
selectedTabIndex = ui.index;
}
});
You can use selectedTabIndex in your app
精彩评论