如图,已根据之前一位大神的帖子把第一列中相同的合并了,现在的情况是:除了第二列,后面的3列要跟着第一列的合并来合并,求来个大神解答,第一列合并的js如下:
<tr>
<td class="hebing" style="text-align: center;">
${honor.honorOrgName }
</td>
.....
</tr>
$('.hebing').each(function(index, element) {
if(!$(this).hasClass('hide'))
{ var next=$(this).parent('tr').next('tr').children('.hebing');//下一个合并的对象
$(this).attr('rowspan',1);
while($(this).text()==next.text())
{
//合并
$(this).attr('rowspan',parseInt($(this).attr('rowspan'))+1);
//文字居中 添加等值的height和line-height
$(this).attr('style',"height:"+((parseInt($(this).attr('rowspan'))+1)*30)+"px;");
$(this).attr('style',"line-height:"+((parseInt($(this).attr('rowspan'))+1)*30)+"px;");
next.hide();
next.addClass('hide');
next=next.parent('tr').next('tr').children('.hebing');//下一个合并的对象
}
}
});