案例:jQuery案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript" src="/js/jquery.js"></script>
4
<script type="text/javascript">
5
$(document).ready(function(){
6
  $("li").click(function(){
7
    alert($(this).index());
8
  });
9
});
10
</script>
11
</head>
12
<body>
13
<p>点击列表项可获得其相对于同胞元素的 index 位置:</p>
14
<ul>
15
<li>Coffee</li>
16
<li>Milk</li>
17
<li>Soda</li>
18
</ul>
19
</body>
20
</html>
21