function hebingRows(col, atrrb) {
var trs = $("table tbody tr");
var rows = 1;
for (var i = trs.length; i > 0; i--) {
var cur = $($(trs[i]).find("td")[col]).attr(atrrb);
var next = $($(trs[i - 1]).find("td")[col]).attr(atrrb);
if (cur == next) {
rows++;
$($(trs[i]).find("td")[col]).remove();
} else {
$($(trs[i]).find("td")[col]).attr("rowspan", rows);
rows = 1;
}
}
}
调用方式:atrrb是根据什么属性合并列
$(function () {
hebingRows(7, "data-dealid");
hebingRows(0, "data-distid");
});