Home > Web Front-end > JS Tutorial > JS sorting output realizes table row number auto-increment using the tr_javascript technique dynamically generated by the front end

JS sorting output realizes table row number auto-increment using the tr_javascript technique dynamically generated by the front end

WBOY
Release: 2016-05-16 16:39:46
Original
1205 people have browsed it

I recently worked on a project that required sorting and outputting the data. It required row numbers, which were incremented by 1.2.3.4.5....

The front end traverses the dynamically output through , the code is as follows:

<!-- 循环生成,列表数据 --> 
<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>
Copy after login

The line number is automatically incremented by 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(); 
});
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template