//行合并插件
jQuery.fn.rowspan = function(colIdx) { //封装的一个JQuery小插件
return this.each(function(){
var that;
$('tr', this).each(function(row) {
$('td:eq('+colIdx+')', this).each(function(col) {
if (that!=null && this.innerText == that.outerText) {
rowspan = $(that).attr("rowSpan");
if (rowspan == undefined) {
$(that).attr("rowSpan",1);
rowspan = $(that).attr("rowSpan");
}
rowspan = Number(rowspan)+1;
$(that).attr("rowSpan",rowspan);
$(that).css("line-height", 50 * rowspan + 'px');
$(this).hide();
} else {
that = this;
}
});
});
});
}
$("#dwgsTable").rowspan(0);
dwgsTable:table的ID
<table class="table table-bordered table-condensed" id="dwgsTable">
<thead>
<tr>
<th style="width: 45px">序号</th>
<th>项目名称</th>
<th>单位工程名称</th>
<th>专业</th>
<th>送审金额</th>
<th>协审人员</th>
<th>协审复核人员</th>
</tr>
</thead>
</table>
版权声明:本文为Marlo原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。