相关疑难解决方法(0)

按行和列号选择表中的任意单元格

我有一个大表,我需要能够使用它的单元格/行坐标选择一个特定的单元格.

使用jQuery执行此操作的最优雅方法是什么?

jquery html-table

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

表cellIndex和rowIndex与colspan/rowspan

我正在使用以下提供的答案:

如何使用jQuery找到每个表格单元格的"可视位置"?

但它似乎在这种情况下不起作用:http://jsfiddle.net/TRr6C/9/

请注意,1,3 1,4和2,4应为1,4 1,5和2,5

有人看到什么错了吗?

或者有没有更好的解决方案从表格单元格中获取cellIndex和rowIndex考虑colspan和rowspan?

这是代码:

function getCellLocation(cell) {

    var cols = cell.closest("tr").children("td").index(cell);
    var rows = cell.closest("tbody").children("tr").index(cell.closest("tr"));
    var coltemp = cols;
    var rowtemp = rows;

    cell.prevAll("td").each(function() {
        cols += ($(this).attr("colspan")) ? parseInt($(this).attr("colspan")) - 1 : 0;
    });

    cell.parent("tr").prevAll("tr").each(function() {
        //get row index for search cells
        var rowindex = cell.closest("tbody").children("tr").index($(this));
        // assign the row to a variable for later use
        var row = $(this);
        row.children("td").each(function() {
            // fetch all cells of this row
            var colindex …
Run Code Online (Sandbox Code Playgroud)

javascript jquery html-table

13
推荐指数
3
解决办法
7057
查看次数

标签 统计

html-table ×2

jquery ×2

javascript ×1