「jQuery入門」テーブルの行列位置を取得するサンプル

2017年12月12日

1.htmlコード
<table border="1″>
<tr>
<td>テストデータAA</td>
<td>テストデータBB</td>
<td>テストデータCC</td>
</tr>
</table>

2.JSコード
$('td’).click(function(){
var row = $(this).closest('tr’).index();
var col = this.cellIndex;
console.log('行: ' + row + ', 列: ' + col);
});

jQuery

Posted by arkgame