// 合并多行为一行
jQuery.fn.rowspan = function(colIdx) { //封装的一个JQuery小插件
return this.each(function(){
let that;
$('tr', this).each(function(row) {
$('td:eq('+colIdx+')', this).each(function(col) {
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).remove();
} else {
that = this;
}
});
});
})};
// 合并table的相同数据,参数是某一列
$("#river").rowspan(1);