<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#cool input").click(function(){
alert($(this).index());
});
});
</script>
</head>
<body>
<p>点击列表项可获得其相对于同胞元素的 index 位置:</p>
<ul id="cool">
<input type="button" value="0">
<input type="button" value="1">
<input type="button" value="2">
</ul>
</body>
</html>
转载于:https://blog.51cto.com/13238147/2360890