小编sca*_*n29的帖子

单击HTML表并获取行号(使用Javascript,而不是jQuery)

我想知道如何单击HTML表中的按钮并获取返回给我的行和列号:例如,使用下表:

<table>
  <tr>
    <td><input type="button" value="button"></td>
    <td><input type="button" value="button"></td>
    <td><input type="button" value="button"></td>
    </tr>
    <tr>
    <td><input type="button" value="button"></td>
    <td><input type="button" value="button"></td>
    <td><input type="button" value="button"></td>
    </tr>
    <tr>
    <td><input type="button" value="button"></td>
    <td><input type="button" value="button"></td>
    <td><input type="button" value="button"></td>
    </tr>
  </table>
Run Code Online (Sandbox Code Playgroud)

我如何使用JavaScript点击第二行中的第一个按钮并让它告诉我,我点击了第二行中的第一个单元格?每个按钮是否需要具有唯一ID?

html javascript row html-table

19
推荐指数
2
解决办法
5万
查看次数

标签 统计

html ×1

html-table ×1

javascript ×1

row ×1