<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>