<div class="codetitle"> <span><a style="CURSOR: pointer" data="31957" class="copybut" id="copybut31957" onclick="doCopy('code31957')"><u>複製代碼</u></a></span>如下代碼:</div> <div class="codebody" id="code31957"> <br><br> <br> <meta http content="text/html;腳本=「javascript」><BR> var n = 0;<BR> function showTable(len) {<BR> wi('<table border=" width="300" style="bap-collse:coll<table ><tbody id=" table>');<br> for (i=0;i<len> if (parseInt(i%2) )==1) {<br> if (parseInt(i%2) )==1) {<br> '#F4FAC7';<br> } else {<br> bg = '白色'; <br> }<br> wi('<tr bgcolor=" bg "><td>第' (i 1) '行</td></tr>'); <br> }<br> wi('<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") document .createElement("td");<br> td.innerHTML = '第' (10 n) '行';<br> tr.appendChild(td);<br> <br> <br> <br> <br><br></len> </div>