如何在同一位置找出下一行的td索引 [英] How to find out the index of td in next row in same position

查看:76
本文介绍了如何在同一位置找出下一行的td索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a html page. It contains table. I want to find out a particular cell's index which is in the same position. ie, Here is my table,
<pre lang="HTML">
<table border="1">
   <tr>
      <td rowspan="2">Label 1</td>
      <td rowspan="2">Label 2</td>
      <td colspan="2">Label 3</td>
      <td>Something else</td>
   </tr>
   <tr>
      <td>Item 1</td>
      <td>Item 2</td>
      <td>Item 3</td>
   </tr>
   <tr>
      <td> 1</td>
      <td> 2</td>
      <td> 3</td>
      <td> 4</td>
      <td> 5</td>
   </tr>
</table>
</pre>
Here I want to find the index of the next row's td in the same position of item2.(ie, index of 4) . How it is possible with jQuery? (if click item 2 , i want to alert index of<td>4</td><pre lang="HTML"></pre>)

推荐答案

< br>

(table tr td)。click(function(){
var currentIndex =
("table tr td").click(function () { var currentIndex =


(this).index();
(this).index();


这篇关于如何在同一位置找出下一行的td索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆