标签:class script ack www asp 页面 doc charset element
页面展示的表格第一列自动编号,如图
代码如下:
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>自动编号</title> 6 </head> 7 8 <script language="javascript" type="text/javascript"> 9 window.onload = function () { 10 var tableLine = document.getElementById("number"); 11 for (var i = 0; i < tableLine.rows.length; i++) { 12 tableLine.rows[i].cells[0].innerHTML = (i + 1); 13 } 14 } 15 </script> 16 <body> 17 18 <table> 19 <tr> 20 <td>编号</td> 21 <td>内容</td> 22 </tr> 23 <tbody id="number"> 24 <tr> 25 <td></td> 26 <td>一</td> 27 </tr> 28 29 <tr> 30 <td></td> 31 <td>二</td> 32 </tr> 33 34 <tr> 35 <td></td> 36 <td>三</td> 37 </tr> 38 </tbody> 39 </table> 40 41 </body> 42 </html>
参考:https://www.qwbm.com/new.asp?id=801
标签:class script ack www asp 页面 doc charset element
原文地址:https://www.cnblogs.com/whycai/p/14453895.html