我如何获得当前使用JavaScript表的rowindex? [英] How do i get current rowindex of table using javascript?

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

问题描述

今天你好,我有一个问题。我可以在javascript中获取表格的当前行索引吗?我们可以用当前索引删除表的行吗?

解决方案


rowIndex属性返回表中行的位置


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

 <表> < tr onclick =myFunction(this)> < td>点击以显示rowIndex< / td> < / TR> < tr onclick =myFunction(this)> < td>点击以显示rowIndex< / td> < / TR> < tr onclick =myFunction(this)> < td>点击以显示rowIndex< / td> < / TR> < tr onclick =myFunction(this)> < td>点击以显示rowIndex< / td> < / table>  


Hello today I have one question. Can I get current row index of table in javascript ? and can we remove row of table with current Index that we got?

解决方案

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天全站免登陆