Hi there,

You could the following a try:

$(document).ready(function() {

var index = $("#mymenu ul li").index( $("li:has(#link_y)") );

// index will store the 'index' of <li> tag that has id=link_y

});


Hope this helps,

Thanks,

Abdullah.


On May 14, 8:31 am, Jo <jo.arg...@gmail.com> wrote:
> My question is quite simple with an example:
>
> <div id="mymenu">
>  <ul>
>   <li><a id="link_x" href="#">label X</a></li>
>   <li><a id="link_y" href="#">label Y</a></li>
>   <li><a id="link_z" href="#">label Z</a></li>
>   <li><a id="link_w" href="#">label W</a></li>
>  </ul>
> </div>
>
> I would like to know the index of the <li> tag containing the
> hyperlink with id "link_y" : in this example, it should be 1, but if
> for any reason I re-order the links, alphabetically for example, it
> should become 2.
>
> Thanks for your help!
>
> -- J:o)

Reply via email to