(转)jquery合并单元格

文章原文:https://blog.csdn.net/qq422431474/article/details/53318374

//合并单元格
    jQuery.fn.rowspan = function (colIdx) {
        return this.each(function () {
            var that, rowspan;
            $('tr', this).each(function () {
                $('td:eq(' + colIdx + ')', this).filter(':visible').each(function () {
                    console.log(1)
                    if (that != null && $(this).html() == $(that).html()) {
                        rowspan = $(that).attr("rowspan");
                        if (rowspan == undefined) {
                            $(that).attr("rowspan", 1);
                            rowspan = $(that).attr("rowspan");
                        }
                        rowspan = Number(rowspan) + 1;
                        $(that).attr("rowspan", rowspan);
                        $(this).hide();
                    } else {
                        that = this;
                    }
                });
            });
        });
    }

 

posted @ 2019-01-15 18:36  膜拜曾文正  阅读(466)  评论(0编辑  收藏  举报