Javascript examples for jQuery Method and Property:index
Get index of LI in UL by index() function
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.2.js"></script> <script type="text/javascript"> $(window).load(function(){/*from www . jav a 2 s.c o m*/ $(function() { $('ul li').click(function(e) { console.log($(this).index()); }); }); }); </script> </head> <body> <ul> <li>test 1</li> <li>test 2</li> <li>test 3</li> </ul> </body> </html>