且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将onclick事件添加到表列?

更新时间:2023-01-12 10:58:28

是使用jQuery返回行和列号的代码,它必须有帮助
Jsfiddle链接

This is the code to return row and column number using jQuery, it must be helpful Jsfiddle link

$('td').on('click',function() {
                var col = $(this).parent().children().index($(this));
                var row = $(this).parent().parent().children().index($(this).parent());
                alert('Row: ' + row + ', Column: ' + col);
            });