<div class="codetitle"> <span><a style="CURSOR: pointer" data="31957" class="copybut" id="copybut31957" onclick="doCopy('code31957')"><u>复aze代码</u></a></span> 代码如下:</div> <div class="codebody" id="code31957"> <br><html><br> <head><br> < ;meta http-equiv="Content-Type" content="text/html; charset=gb2312"><br> <title>JavaScript</title><br> </head><br> <body> ;<BR> <script 언어="javascript"><br> var n = 0;<br> function showTable(len) {<br> wi('<table border="1" width="300" style="border-collapse:collapse"><tbody id="table">');<br> for (i=0;i<len> if (parseInt(i%2 )==1) {<br> bg = '#F4FAC7';<br> } else {<br> bg = '흰색'; <br> }<br> wi('<tr bgcolor=' bg '><td>第' (i 1) '行</td></tr>'); <br> }<br> wi('</tbody></table><br />');<br> wi('<input type="button" value="Add" id= "추가" />'); <br> }<br> function wi(str) {<br> return document.write(str); <br> }<br> showTable(10);<br> var add = document.getElementById("add");<br> add.onclick = function() {<br> n = n 1;<br> if (n%2==0) {<br> bg = '#F4FAC7';<br> } else {<br> bg = '흰색'; <br> }<br> var table = document.getElementById("table");<br> var tr = document.createElement("tr");<br> tr.bgColor = bg;<br> var td = document .createElement("td");<br> td.innerHTML = '第' (10 n) '行';<br> tr.appendChild(td);<br> table.appendChild(tr);<br> } <br> </script><br> </body><br></html> <br></len> </div>