合并表格相同值的部分行列数据

var _index = 0;
var _value = $("#table tbody tr").eq(0).find("td").eq(1).find("label").text();
$("#table tbody tr").each(function (index, item) {
    var value = $(item).find("td").eq(1).find("label").text();
    if (value != _value) {
        $("#table tbody tr").slice(_index + 1, index).find("td:gt(0):lt(5)").remove();
        $("#table tbody tr").eq(_index).find("td:gt(0):lt(5)").attr("rowspan", index - _index);
        _index = index;
        _value = value;
    }
    else if (index == $("#table tbody tr").length - 1) {
        //处理最后一组数据
        index++;
        $("#table tbody tr").slice(_index + 1, index).find("td:gt(0):lt(5)").remove();
        $("#table tbody tr").eq(_index).find("td:gt(0):lt(5)").attr("rowspan", index - _index);
    }
})
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容