<div class="htmlarea"> <textarea id="runcode30340"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>JavaScript는 자동으로 테이블에 일련 번호를 추가합니다</title> <style type="text/css"> .index_tab{width:100%;border-collapse:collapse;border:1px solid #005892;margin:8px 0;} .index_tab td{line-height:35px;border:1px solid #005892;padding-left:4px;} tr.tr_top td{line-height:32px;border:none;background-color:#005892;color:#fff;font-weight:bold;} td.td_center{text-align:center;} .ys01{background-color:#E6F0FE;} </style> <table class="index_tab"> <tr class="tr_top"> <td class="td_center" width="9%">行号</td> <td width="83%">标题</td> <td class="td_center" width="11%">总计</td> </tr> <tbody id="bbsTab"> <tr> <td class="td_center"></td> <td><a href="#">Vc 支持窗口及文字拖放的COleDropTarget扩展类</a></td> <td class="td_center">20235</td> </tr> <tr> <td class="td_center"></td> <td><a href="#">好用的ICO图标截取工具VB源程序</a></td> <td class="td_center"> </td> </tr> <tr> <td class="td_center"></td> <td><a href="#">一些经典的VB加密解密算法示例</a></td> <td class="td_center"> </td> </tr> <tr> <td class="td_center"></td> <td> </td> <td class="td_center"> </td> </tr> <tr> <td class="td_center"></td> <td> </td> <td class="td_center"> </td> </tr> <tr> <td class="td_center"></td> <td> </td> <td class="td_center"> </td> </tr> </tbody> </table> </textarea> <br><input onclick="runEx('runcode30340')" type="button" value="运行代码"><input onclick="doCopy('runcode30340')" type="button" value="复制代码"> <input onclick="doSave(runcode30340)" type="button" value="保存代码"> <a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">[Ctrl A 모두 선택 참고: </a>외부 J를 도입해야 하는 경우 실행하려면 새로 고쳐야 합니다 </div>]<script language="javascript" type="text/javascript"> window.onload = function(){ var oTable = document.getElementById("bbsTab"); for(var i=0;i<oTable.rows.length;i++){ oTable.rows[i].cells[0].innerHTML = (i+1); if(i%2==0) //偶数行 oTable.rows[i].className = "ys01"; } } </script>