//合并单元格重复列
function tableRowspan(tableId, tableColnum) {
firsttd = "";
currenttd = "";
spanNum = 0;
obj = $(tableId + " tr td:nth-child(" + tableColnum + ")");
obj.each(function (i) {
if (i == 0) {
firsttd = $(this);
spanNum = 1;
} else {
currenttd = $(this);
if (firsttd.text() == currenttd.text()) {
spanNum++;
currenttd.hide();
firsttd.attr("rowSpan", spanNum);
} else {
firsttd = $(this);
spanNum = 1;
}
}
});
}
使用方法:
tableRowspan('#MyTable', '1');//列从1开始