getting a tab name instead of the index
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
精彩评论