Javascript jqueryui选项卡。始终显示以前选择的选项卡索引
下面是获取当前选定选项卡索引的jquery代码。但是,它们都返回以前的选项卡值。我需要当前选定的选项卡索引。请帮忙Javascript jqueryui选项卡。始终显示以前选择的选项卡索引,javascript,jquery,Javascript,Jquery,下面是获取当前选定选项卡索引的jquery代码。但是,它们都返回以前的选项卡值。我需要当前选定的选项卡索引。请帮忙 var selected = $("#enrichmentViewTabs").tabs("option", "selected"); var sel2 = $("#enrichmentViewTabs").tabs().data("selected.tabs"); var sel3 = $("#enrichmentV
var selected = $("#enrichmentViewTabs").tabs("option", "selected");
var sel2 = $("#enrichmentViewTabs").tabs().data("selected.tabs");
var sel3 = $("#enrichmentViewTabs").tabs('option', 'active');
var curTab = $('.ui-tabs-panel:not(.ui-tabs-hide)'),curTabID = curTab.prop("id");
var sel4 = curTab.index();
$("#enrichmentViewTabs").bind("tabsactivate", function(event, ui) {
selected = ui.newTab.index();
});
alert(selected);
您正在访问范围外的选定变量。检查一下:因为您自己的代码可以工作并返回正确的索引/就像任何数组一样,它从0到n开始,所以tap1将有索引0等等on@VishalVaishya非常感谢您的验证。很高兴知道这段代码运行良好。问题一定出在我编写html的方式上。再次感谢。