【jQuery:遍历同样class的全部值,遍历某一列td的值】
jsp代码:
Html代码
- <c:forEach var="main" items="${mainPage.list }">
- <tr>
- <td><a class="sceneStr_td">${main.sceneStr }</a></td>
- <td class="concern">${main.concernedNumber }</td>
- <td class="noConcern">${main.noConcernedNumber }</td>
- <td class="validateNumber">${main.validateNumber }</td>
- <td>${main.createTime }</td>
- <td>${main.delFlag==0?
'同意':'不同意' }</td>
- <td>
- <a href="${main.url }" target="_blank">二维码链接</a>
- </td>
- </tr>
- </c:forEach>
- <tr class="count_main">
- <th style="text-align: center;">统计:</th>
- <td class="count_concern">0</td>
- <td class="count_noConcern">0</td>
- <td class="count_validateNumber">0</td>
- <td></td>
- <td></td>
- <td></td>
- </tr>
复制代码
js代码:
Html代码
- var main_list_size = $(".main_list_size").val();//获取主单循环大小
- main_list_size = parseInt(main_list_size);
- var count_concern = parseInt(0);
- var count_noConcern = parseInt(0);
- var count_validateNumber = parseInt(0);
- if(main_list_size<=0){
- $(".count_main").hide();//没有数据时,隐藏该行
- }else{
- var concern = $(".concern noConcern validateNumber");
- for(var i=0;i<main_list_size;i++){
- count_concerncount_concern = count_concern+ parseInt($(".concern").eq(i).html());
- count_noConcerncount_noConcern = count_noConcern + parseInt($(".noConcern").eq(i).html());
- count_validateNumbercount_validateNumber = count_validateNumber + parseInt($(".validateNumber").eq(i).html());
- }
- $(".count_concern").html(count_concern);
- $(".count_noConcern").html(count_noConcern);
- $(".count_validateNumber").html(count_validateNumber);
- $(".count_main").show();//有数据时。显示该行
- }
复制代码
这样。以下的统计信息就全出来了
原文地址 java社区 http://techfoxbbs.com/thread-2646-1-1.html