<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
<script>
var mycars = new Array()
function displayResult(){
for(var i=0;i<2;i++){
mycars[i]=document.getElementById("myTable").rows[i].cells[1].innerHTML;
}
for (var j=0;j<mycars.length;j++)
{
alert(mycars[j]);
}
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td>cell 1</td>
<td>cell 2</td>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">显示第一行单元格的数量</button>
</body>
</html>