jsp中td值相同合并的问题

花生丶 2017-11-17 11:20:42



如图,已根据之前一位大神的帖子把第一列中相同的合并了,现在的情况是:除了第二列,后面的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');//下一个合并的对象
}
}
});
...全文
200 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧