基于jQuery的jsp表格动态合并

基于jQuery的jsp表格动态合并

代码展示

 <tr>
     <th style="text-align: center" >申报编号</th>
      <th style="text-align: center">使用单位</th>
      <c:if test="${sbzl ne '3002'}">
          <th style="text-align: center">设备注册代码</th>
      </c:if>
      <c:if test="${sbzl eq '3002'}">
          <th style="text-align: center">特种设备编号</th>
      </c:if>
      <th style="text-align: center">设备种类</th>
      <th style="text-align: center">检验类型</th>
      <th style="text-align: center">检验内容</th>
      <c:if test="${sbzl eq '5000'}">
          <th>车牌号</th>
          <th>燃油种类</th>
      </c:if>
      <c:if test="${jyxz eq '1'}">
          <c:if test="${sbzl ne '5000'}">
              <th style="text-align: center">检验日期</th>
          </c:if>
      </c:if>
      <c:if test="${sessionScope.ishb eq '1'}">
          <th>操作</th>
      </c:if>
</tr>
<c:forEach items="${jynrlblist}" varStatus="jynr" var="ggWssbJynrlb" >
 <tr align="center">
   <td class="sbbhHebing">
     <input type="hidden" id="wssbid_${jynr.count}" value="${ggWssbJynrlb.wssbid}"/>
      <input id="declareNum_${jynr.count}" value="${ggWssbJynrlb.sbbh}"/>
      <input type="hidden" name="sbzl" id="sbzl${jynr.count}" value="${ggWssbJynrlb.sbzl}"/>
   </td>
   <td>
      ${ggWssbJynrlb.sydwmc}
   </td>
	<c:if test="${sessionScope.ishb eq '1'}">
	   <td colspan="5" class="hebing">
	   <input id="btnSubmitbz" onclick="addDeviceWindwo('${ggWssbJynrlb.wssbid}');" value="录入备注"/>
	   </td>
	</c:if>
 </tr>
</c:forEach>

js处理

<script>
 $(function(){
   $(".hebing").each(function(index, element) {
     if(!$(this).hasClass('hide')){
       var next=$(this).parent('tr').next('tr').children(".hebing") // 
       var last=$(this).parent('tr').children(".sbbhHebing")  //本行的第一个框里面的值
       var nextlast=$(this).parent('tr').next('tr').children(".sbbhHebing")//下一行第一个框里面的值
        $(this).attr("rowspan",1);  //初始值
        while(last.text()==nextlast.text()){
          $(this).attr("rowspan",parseInt($(this).attr("rowspan"))+1); // 合并框
          next.hide();
          next.addClass('hide');
          next=next.parent('tr').next('tr').children(".hebing");
          last=last.parent('tr').children(".sbbhHebing")
          nextlast=nextlast.parent('tr').next('tr').children(".sbbhHebing")
       }
     }
  })
});
</script>

效果
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值