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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -