Tryit Editor v1.8

Source Code:
<!DOCTYPE html> <html> <head> <script src="../../ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("li").click(function(){ alert($(this).index()); }); }); </script> </head> <body> <p>Click the list items to get the index position, relative to its sibling elements</p> <ul> <li>Coffee</li> <li>Milk</li> <li>Soda</li> </ul> </body> </html>
Result:
W3Schools.com - Try it yourself