- <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>
来源: http://www.bubuko.com/infodetail-2984683.html