get the tab text on select jquery ui tabs

跟風遠走 提交于 2020-01-02 02:11:04

问题


I m using jquery ui tabs

I can get the index of the selected tab on "load" (ajax) event

$('#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


回答1:


You can use the ui argument passed in, specifically ui.tab to get the anchor element, like this:

var text = $(ui.tab).text();

I don't have your pages to load, but you can test a demo here using the select event, it works the same way.



来源:https://stackoverflow.com/questions/3718703/get-the-tab-text-on-select-jquery-ui-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!