最近做一項(xiàng)目,需要對數(shù)據(jù)進(jìn)行排序輸出,要求有行號,依次遞增1.2.3.4.5.......。
前端通過<c:forEach> 遍歷動(dòng)態(tài)輸出的<tr>
代碼如下:
view sourceprint?01 <!-- 循環(huán)生成,列表數(shù)據(jù) -->
02 <c:forEach items="${pager.list}" var="auction">
03 <tr class="bg1">
04 <td width="10" align="center"><span class="numberClass"></span></td>
05 <td width="30" align="center">${auction.dept}</td>
06 <td width="40" align="center">${auction.donor}</td>
07 <td width="40" align="center">¥:${auction.auctionSum}.00</td>
08 <td width="40" align="center"><span onClick="displayDetails('xxxx}')" style="color:blue;cursor:pointer;">查看詳細(xì)信息</span></td>
09 </tr>
10 </c:forEach>
行號自增js代碼(需引入jquery):
view sourceprint?1 $(function(){
2 function number(){
3 for(var i=0;i< $(".numberClass").length;i++){
4 $(".numberClass").get(i).innerHTML = i+1;
5 }
6 }
7 number();
8 });
更多信息請查看IT技術(shù)專欄