javascript - Index number clicks -


trying show index of bunch of clicked links in ul.

<ul class="menu">     <li><a href="#">slide 1</a></li>     <li><a href="#">slide 2</a></li>     <li><a href="#">slide 3</a></li> </ul>  $(".menu li a").click(function(e){     e.preventdefault();     slideindex = $(this).index();     console.log(slideindex);  }); 

now in console shows 0, have missed here? want show 1 or 2 if click other 2 links. guess elementary little unsure.

change to:

$(".menu li").click(function(e){     e.preventdefault();     slideindex = $(this).index();     console.log(slideindex);  }); 

otherwise checking index of a in li, 0, there 1 a in every li.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -