Get tab selected Id in jQuery UI 1.9

2019-09-03 21:22发布

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.

5条回答
欢心
2楼-- · 2019-09-03 21:37

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

查看更多
We Are One
3楼-- · 2019-09-03 21:44

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楼-- · 2019-09-03 21:44
$('#divName .ui-tabs-panel[aria-hidden="false"]').prop('id');
查看更多
仙女界的扛把子
5楼-- · 2019-09-03 21:46

Try this:

$('#chart-report-tabs .ui-tabs-panel[aria-hidden="false"]').prop('id');
查看更多
Fickle 薄情
6楼-- · 2019-09-03 21:50

Try this one:

$("#<id of tabs>").tabs("option","active")

Returns zero-based index of active tab

查看更多
登录 后发表回答