<div class="codetitle"> <span><a style="CURSOR: pointer" data="19849" class="copybut" id="copybut19849" onclick="doCopy('code19849')"><u>复代码</u></a></span> 代码如下:</div> <div class="codebody" id="code19849"> <br><br><title>;遍历表格</title><br><script 언어="javascript"><br> function getData()<br> {<br> var arrData=new Array();<br> var objTable=document. getElementById("myTable");<br> if(objTable)<br> {<br> for(var i=0;i<objTable.rows.length;i )<BR> {<BR> for(var j= 0;j<objTable.rows[i].cells.length;j )<BR> {<BR> arrData[i]=objTable.rows[i].cells[j].innerText;<BR> }<BR> }<BR> }<BR> Alert(arrData.join(","));<BR> }<BR></script><br></head><br><body><br> <table border="1" id="myTable"><br><tr><td>liu</td><td>jin</td><td>cai</td>< ;/tr><br><tr><td>liu2</td><td>jin2</td><td>cai2</td></tr><br><tr> <td>liu3</td><td>jin3</td><td>cai3</td></tr><br></table><br><form><br> <input type="button" value="getData" onclick="getData();" /><br></form><br></body><br></html><br> </title> </div> <br>