开发者

getting a tab name instead of the index

开发者 https://www.devze.com 2023-04-05 15:16 出处:网络
I have an application that updates databases based on the tabs name been clicked on. I need to be able to get the tab\'s name using the index number.

I have an application that updates databases based on the tabs name been clicked on. I need to be able to get the tab's name using the index number.

<div id="id_tabs" class="tabs" > </div>
<ul class="d_tabs">
  <li id="id_tab_home"><a href="#tab_home">Home</div>     </a></li>
  <li id="id_tab_first"><a href="#tab_first">First</div></a></li>
  <li id="id_tab开发者_StackOverflow_second"><a href="#tab_second">Second</div></a></li>
</ul>


$('ul.d_tabs li').eq(idx).attr("id") will return the ID (string) for whatever idx (number) you feed it.


First of all your HTML code is not valid, </div> is closed before </a> fix that

code for getting name is like this in click method

var name = $('#' + $(this).attr('id') + ' a:first-child').html();

and that is it

0

精彩评论

暂无评论...
验证码 换一张
取 消