如何使用Javascript获取表的当前rowindex? [英] How do I get current rowindex of a table using Javascript?

查看:572
本文介绍了如何使用Javascript获取表的当前rowindex?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在Javascript中获取表的当前行索引吗,是否可以删除具有当前索引的表行?

Can I get current row index of a table in Javascript and can we remove the row of table with current Index that we got?

推荐答案

rowIndex属性返回表中一行的位置

The rowIndex property returns the position of a row in table

function myFunction(x) {
  console.log("Row index is: " + x.rowIndex);
}

<table>
  <tr onclick="myFunction(this)">
    <td>Click to show rowIndex</td>
  </tr>
  <tr onclick="myFunction(this)">
    <td>Click to show rowIndex</td>
  </tr>
  <tr onclick="myFunction(this)">
    <td>Click to show rowIndex</td>
  </tr>
  <tr onclick="myFunction(this)">
    <td>Click to show rowIndex</td>
  </tr>
</table>

这篇关于如何使用Javascript获取表的当前rowindex?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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