码迷,mamicode.com
首页 > 其他好文 > 详细

foreach循环遍历 行合并

时间:2018-01-26 00:30:42      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:stat   row   status   ccf   web   for   c99   black   count   

<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<style type="text/css">

table{
border: 1px solid black;
border-collapse: collapse;
}
td{
border: 1px solid black;
text-align: center;
}
</style>
</head>
<body>
<table align="center" width="650px">
<tr bgcolor="#CCFFFF">
<td>序号</td>
<td colspan="2">项目</td>
<td>1月</td>
<td>2月</td>
<td>3月</td>
<td>x年合计</td>
</tr>
<c:forEach items="${configApp}" var="configAppname" varStatus="index">
<c:set var="ca" value="${configAppname.configProjectType.projectName}"/>
<c:set var="count" value="0"/>
<c:forEach items="${configApp}" var="configApps">
<c:if test="${configApps.configProjectType.projectName==ca}">
<c:set var="count" value="${count+1}"/>
</c:if>
</c:forEach>
<tr>
<td>${index.count}</td>
<td class="hebing">${configAppname.configProjectType.projectName}</td>
<td>${configAppname.appName}</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
</tr>
</c:forEach>

<tr>
<td></td>
<td colspan="2">项目收入合计</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
</tr>
</table>
</body>
</html>
<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
<script>
$(function(){
    $(‘.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);
                    next.hide();
                    next.addClass(‘hide‘);
                    next=next.parent(‘tr‘).next(‘tr‘).children(‘.hebing‘);//下一个合并的对象
                }
        }
    });
});
</script>

 

foreach循环遍历 行合并

标签:stat   row   status   ccf   web   for   c99   black   count   

原文地址:https://www.cnblogs.com/wxm-bk/p/8353641.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!