页面动态table动态合并table

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");
});

上一篇:PHP CLI编程基础知识积累(进程、子进程、线程)


下一篇:怎样用 Bash 编程:语法和工具