如下图展示 :求出总数
使用jquery强大的选择器来计算
1.. jsp代码如下
<table class="data-list">
<tr>
<th class="brl-none">章节</th>
<th><font color="red">试题数量</font></th>
<th>新导入</th>
<th>要录视频</th>
<th>不录视频</th>
<th><font color="green">待消重</th>
<th><font color="red">已有视频</font></th>
<th>总分的试题</th>
<th>未总分</th>
<th>已总分</th>
<th>未处理</th>
<th>绑定考察点</th>
<th>完成任务</th>
</tr>
<ww:iterator value="chapterIdQueNumList" status="queNumListStatus">
<tr>
<td class="brl-none">
<span id="td_a<ww:property value='#queNumListStatus.count'/>">
<ww:property value='kname'/>
</span>
</td>
<td >
<font color="red">
<span id="td_b<ww:property value='#queNumListStatus.count'/>">
<ww:property value="quenum" default="0"/>
</span>
</font>
</td>
<td >
<span id="td_c<ww:property value='#queNumListStatus.count'/>">
<ww:property value="newimportquenum" default="0"/>
</span>
</td>
<td >
<span id="td_d<ww:property value='#queNumListStatus.count'/>">
<ww:property value="recordvideoquenum" default="0"/>
</span>
</td>
<td >
<span id="td_e<ww:property value='#queNumListStatus.count'/>">
<ww:property value="norecordvideoquenum" default="0"/>
</span>
</td>
<td >
<font color="green">
<span id="td_f<ww:property value='#queNumListStatus.count'/>">
<ww:property value="waitduplicatequenum" default="0"/>
</span>
</font>
</td>
<td >
<font color="red">
<span id="td_g<ww:property value='#queNumListStatus.count'/>">
<ww:property value="hadvideoquenum" default="0"/>
</span>
</font>
</td>
<td >
<span id="td_h<ww:property value='#queNumListStatus.count'/>">
<ww:property value="totalfenpei" default="0"/>
</span>
</td>
<td >
<span id="td_i<ww:property value='#queNumListStatus.count'/>">
<ww:property value="nofirstfenpei" default="0"/>
</span>
</td>
<td >
<span id="td_j<ww:property value='#queNumListStatus.count'/>">
<ww:property value="firstfenpei" default="0"/>
</span>
</td>
<td >
<span id="td_k<ww:property value='#queNumListStatus.count'/>">
<ww:property value="nodual" default="0"/>
</span>
</td>
<td >
<span id="td_l<ww:property value='#queNumListStatus.count'/>">
<ww:property value="binddegree" default="0"/>
</span>
</td>
<td >
<span id="td_m<ww:property value='#queNumListStatus.count'/>">
<ww:property value="taskcomplete" default="0"/>
</span>
</td>
</tr>
</ww:iterator>
<tr>
<td class="brl-none">
<span id="tdt_a">总数</span>
</td>
<td >
<font color="red">
<span id="tdt_b"></span>
</font>
</td>
<td >
<span id="tdt_c"></span>
</td>
<td >
<span id="tdt_d"></span>
</td>
<td >
<span id="tdt_e"></span>
</td>
<td >
<font color="green">
<span id="tdt_f"></span>
</font>
</td>
<td >
<font color="red">
<span id="tdt_g"></span>
</font>
</td>
<td >
<span id="tdt_h"></span>
</td>
<td >
<span id="tdt_i"></span>
</td>
<td >
<span id="tdt_j"></span>
</td>
<td >
<span id="tdt_k"></span>
</td>
<td >
<span id="tdt_l"></span>
</td>
<td >
<span id="tdt_m"></span>
</td>
</tr>
</table>
2.. js 代码 如下
$(function(){
var tdt = 0;
// 有多少列,就依次向上增加 var arr=["b","c","d","e","f","g","h","i","j","k","l","m"]; for(i=0; i<arr.length;i++){ tdt = 0; $("span[id^=td_"+arr[i]+"]").each(function(){ tdt = tdt + parseInt($(this).text()); }); $("#tdt_"+arr[i]).text(tdt); } });