相关疑难解决方法(0)

表jQuery中的行和列号

如何使用jQuery获取单击的表格单元格的行号和列号,即

$("td").onClick(function(event){
   var row = ...
   var col = ...
});
Run Code Online (Sandbox Code Playgroud)

jquery

135
推荐指数
5
解决办法
23万
查看次数

使用jQuery通过索引获取td

我知道如何使用jQuery获取单元格的行和列索引,但我无法弄清楚相反的情况.给定行和列索引,我将如何访问此位置的td?

html javascript indexing jquery html-table

34
推荐指数
2
解决办法
7万
查看次数

在表行中查找td元素位置

我如何在表格行中找到td元素的位置?我已经看到了这个代码的建议,但有没有办法让每个td标记包含一个onclick事件?

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

<script>
 function myFunction(x) {
   alert("Cell index is: " + x.cellIndex);
}
</script>
Run Code Online (Sandbox Code Playgroud)

我有一个图像网格,我试图看到网格中的哪些图像被点击.我试过这个:

$('td img').on('click', function(x){
   console.log("Cell index is: " + x.cellIndex); 
});
Run Code Online (Sandbox Code Playgroud)

但它只是记录 undefined

html javascript jquery

2
推荐指数
1
解决办法
4201
查看次数

标签 统计

jquery ×3

html ×2

javascript ×2

html-table ×1

indexing ×1