jQuery UI-重新加载选定的选项卡? [英] Jquery UI - reload selected tab?

查看:95
本文介绍了jQuery UI-重新加载选定的选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以重新加载选定的选项卡,我知道有.load()函数.但是它需要一个选项卡索引,而且我似乎没有找到一种方法来获取所选的选项卡ID.

Is there a way to reload the selected tab I know there is the .load() function. But it wants a tab index and I don't seem to see a way to grab the selected tabs id.

推荐答案

更新:在jQuery 1.9中,selected选项重命名为active.参见 attomman的答案.

Update: In jQuery 1.9, the selected option is renamed to active. See attomman's answer.

要获取当前选定的索引,请使用tabs('option','selected')函数.

To get the currently selected index, use the tabs('option','selected') function.

例如,如果您有一个要获取索引的按钮#button(并且#tabs元素被制成了选项卡),请执行以下操作:

E.g, if you have a button #button (and the #tabs element is made into tabs) where you want to get the index, do the following:

$("#button").click(function() {
    var current_index = $("#tabs").tabs("option","selected");
});

这是一个演示: http://jsfiddle.net/sVgAT/


要回答标题所指示的问题,在jQuery 1.8及更早版本中,您可以这样做:


To answer the question indicated by the title, in jQuery 1.8 and earlier, you would do:

var current_index = $("#tabs").tabs("option","selected");
$("#tabs").tabs('load',current_index);

在jQuery 1.9和更高版本中,您可以这样做:

And in jQuery 1.9 and later, you would do:

var current_index = $("#tabs").tabs("option","active");
$("#tabs").tabs('load',current_index);

这篇关于jQuery UI-重新加载选定的选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆