Recently, I have been working on a project and need to sort and output the data. It requires a line number and increment it by 1.2.3.4.5........
The front-end traverses the dynamic output <tr> through <c:forEach>, and the code is as follows:
<!-- Loop generation, list data --> <c:forEach items="${pager.list}" var="auction"> <tr> <td align="center"><span></span></td> <td align="center">${auction.dept}</td> <td align="center">${auction.donor}</td> <td align="center">${auction.donor}</td> <td align="center">¥:${auction.auctionSum}.00</td> <td align="center"><span onClick="displayDetails('xxxx}')" style="color:blue;cursor:pointer;">View details</span></td> </tr> </c:forEach>Line number increments js code (jquery needs to be introduced):
$(function(){ function number(){ for(var i=0;i< $(".numberClass").length;i++){ $(".numberClass").get(i).innerHTML = i+1; } } number(); });