I think this will do it for you:
$("li").click(function () {
alert($(this).index());
});
Note that the index () function returns the index of the element in the jquery collection. If there are multiple lists on a page, make sure your selector selects only the list items you want.
source
share