问题
How can I get the tab selected Id in jQuery UI 1.9?
I use this method in jQuery UI 1.8 :
var key = $('#chart-report-tabs .ui-tabs-panel:not(.ui-tabs-hide)').prop('id');
but it does not work in the 1.9 version.
回答1:
Try this:
$('#chart-report-tabs .ui-tabs-panel[aria-hidden="false"]').prop('id');
回答2:
Try this one:
$("#<id of tabs>").tabs("option","active")
Returns zero-based index of active tab
回答3:
Try this:
var $tabs = $('#chart-report-tabs');
var index = $tabs.tabs('option', 'selected');
var key = $tabs.tabs("option", "panel").find('.ui-tabs-panel').eq(index).prop('id');
Source: jQuery UI Tabs selected index
回答4:
Use the activate
or beforeActivate
events with ui.newPanel
:
$('#chart-report-tabs').tabs({
activate: function(e, ui) {
var key = $(ui.newPanel).prop('id');
}
});
Check the documentation
回答5:
$('#divName .ui-tabs-panel[aria-hidden="false"]').prop('id');
来源:https://stackoverflow.com/questions/13229139/get-tab-selected-id-in-jquery-ui-1-9