Posted in Javascript onJuly 10, 2013
<html> <head><title>遍历表格</title> <script language="javascript"> function getData() { var arrData=new Array(); var objTable=document.getElementById("myTable"); if(objTable) { for(var i=0;i<objTable.rows.length;i++) { for(var j=0;j<objTable.rows[i].cells.length;j++) { arrData[i]=objTable.rows[i].cells[j].innerText; } } } alert(arrData.join(",")); } </script> </head> <body> <table border="1" id="myTable"> <tr><td>liu</td><td>jin</td><td>cai</td></tr> <tr><td>liu2</td><td>jin2</td><td>cai2</td></tr> <tr><td>liu3</td><td>jin3</td><td>cai3</td></tr> </table> <form> <input type="button" value="getData" onclick="getData();" /> </form> </body> </html>
关于js遍历表格的实例
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@