x
 
            
 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Fmpq教程(fmpq.com)</title>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
</script>
<script>
$(document).ready(function(){
    $("li").click(function(){
        alert($(this).index());
    });
});
</script>
</head>
<body>
<p>点击获取列表项的索引位置,相对于它的兄弟元素</p>
<ul>
<li>Coffee</li>
<li>Milk</li>
<li>Soda</li>
</ul>
</body>
</html>