JS 排序输出实现table行号自增前端动态生成的tr
最近做一项目,需要对数据进行排序输出,要求有行号,依次递增1.2.3.4.5.......。
前端通过<c:forEach> 遍历动态输出的<tr>,代码如下:
<!-- 循环生成,列表数据 --> <c:forEach items="${pager.list}" var="auction"> <tr class="bg1"> <td width="10" align="center"><span class="numberClass"></span></td> <td width="30" align="center">${auction.dept}</td> <td width="40" align="center">${auction.donor}</td> <td width="40" align="center">¥:${auction.auctionSum}.00</td> <td width="40" align="center"><span onClick="displayDetails('xxxx}')" style="color:blue;cursor:pointer;">查看详细信息</span></td> </tr> </c:forEach>
行号自增js代码(需引入jquery):
$(function(){ function number(){ for(var i=0;i< $(".numberClass").length;i++){ $(".numberClass").get(i).innerHTML = i+1; } } number(); });
相关推荐
88274956 2020-11-03
runner 2020-09-01
梦的天空 2020-08-25
移动开发与培训 2020-08-16
ReunionIsland 2020-08-16
lyqdanang 2020-08-16
MyNameIsXiaoLai 2020-07-08
星辰的笔记 2020-07-04
csstpeixun 2020-06-28
letheashura 2020-06-26
liaoxuewu 2020-06-26
sunzhihaofuture 2020-06-21
FEvivi 2020-06-16
坚持着执着 2020-06-16
waterv 2020-06-14
xiaoge00 2020-06-14
firejq 2020-06-14
firstboy0 2020-06-14
e度空间 2020-06-12
zhongweinan 2020-06-10