jquery - How to get tab by child element -


with jquery ui tabs, there way tab index child element?

example:

<div id="tabs">     <ul>         <li><a href="#tabs-1">first</a></li>         <li><a href="#tabs-2">second</a></li>     </ul>      <div id="tabs-1">         <input type="text" id="name">     </div>     <div id="tabs-2">         <input type="text" id="age">     </div> </div> 

script:

$("#tabs").tabs(); 

how index of tab element $("#age") is?

this might you:

$(function() {     var parentid,tabindex;      $( "#tabs" ).tabs();      parentid = $("#age").parents("div[id*='tabs']").attr("id");     tabindex = $("li a[href='#"+parentid+"']").parents("li").index();      console.log("#age : "+ tabindex); }); 

here fiddle.


Comments