javascript 获取选择 jquery ui 选项卡上的选项卡文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3718703/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
get the tab text on select jquery ui tabs
提问by Pradyut Bhattacharya
I m using jquery ui tabs
我正在使用 jquery ui 选项卡
I can get the index of the selected tab on "load" (ajax) event
我可以在“加载”(ajax)事件中获取所选选项卡的索引
$('#tabs').tabs(
{
load: function(e, ui) {
if($('#tabs').tabs('option','selected') == 0) { }
}
});
Now i want to get the tab name
现在我想获取标签名称
for eg...
例如...
<ul>
<li><a href="newprofile.jsp"><span>Profile</span></a></li>
<li><a href="ashout.jsp" id="friends"><span>Shouts</span></a></li>
</ul>
I want to retrieve the text Profile when first tab is clicked or Shout when second tab is clicked.
我想在单击第一个选项卡时检索文本配置文件或单击第二个选项卡时大喊。
Thanks
谢谢
回答by Nick Craver
You can use the uiargumentpassed in, specifically ui.tabto get the anchor element, like this:
您可以使用传入的ui参数,特别ui.tab是获取锚元素,如下所示:
var text = $(ui.tab).text();
I don't have your pages to load, but you can test a demo here using the selectevent, it works the same way.
我没有要加载您的页面,但您可以在此处使用selectevent测试演示,它的工作方式相同。

