How would i go about getting the index position number of one of the nested LI s? I can get the topnav index s but cannot seem the children index number of the subnav(s).
I would like to create the selector dynamically to target the subnav based on the index of the topnav.
<div id="nav_container">
<ul id="topnav">
<li><a href="#a">menu item 0</a>
<ul id="subnav0">
<li><a href="#">sub menu item</a></li>
<li><a href="#">sub menu item</a></li>
<li><a href="#">sub menu item</a></li>
<li><a href="#">sub menu item</a></li>
<li><a href="#">sub menu item</a></li>
</ul>
</li>
<li><a href="#a">menu item 1</a>
<ul id="subnav1">
<li><a href="#">sub menu item</a></li>
<li><a href="#">sub menu item</a></li>
<li><a href="#">sub menu item</a></li>
</ul>
</li>
<li><a href="#">menu item 2</a></li>
<li><a href="#">menu item 3</a></li>
</ul>
</div>
My j Query Code
//Event Handler
function nav_execute(){
var _index = $( #topnav > li ).index(this);//Returns index number of topnav item selected
var _subnav = #subnav + _index.toString();
var _selector = _subnav + > li .toString();//the subnav selector
var _subindex = $(_selector).index();//gets total num of index s
}
//Binded event
$( #topnav > li ).bind( click , nav_execute);