Ren*_*ari 7 jquery jquery-ui jquery-ui-tabs
有没有办法重新加载选定的选项卡我知道有.load()函数.但它想要一个标签索引,我似乎没有看到一种方法来获取选定的标签ID.
Sim*_*olt 24
更新:在jQuery 1.9中,该selected选项被重命名为active.请参阅attomman的回答.
要获取当前选定的索引,请使用该tabs('option','selected')功能.
例如,如果您想要获取索引的按钮#button(并且#tabs元素被制作成选项卡),请执行以下操作:
$("#button").click(function() {
var current_index = $("#tabs").tabs("option","selected");
});
Run Code Online (Sandbox Code Playgroud)
这是一个演示:http://jsfiddle.net/sVgAT/
var current_index = $("#tabs").tabs("option","selected");
$("#tabs").tabs('load',current_index);
Run Code Online (Sandbox Code Playgroud)
在jQuery 1.9及更高版本中,您可以:
var current_index = $("#tabs").tabs("option","active");
$("#tabs").tabs('load',current_index);
Run Code Online (Sandbox Code Playgroud)
小智 7
Simen确实得到了正确的答案,但自从JQuery UI 1.9以来,它已经被弃用了
http://jqueryui.com/upgrade-guide/1.9/#deprecated-selected-option-renamed-to-active
您现在使用'有效'而不是'已选中'
所以代码看起来像:
var current_index = $("#tabs").tabs("option","active");
$("#tabs").tabs('load',current_index);