代码编辑器:
x
1
<script>
2
function displayResult(){
3
alert(document.getElementById("myTable").rows[0].cells.length);
4
}
5
</script>
6
<table id="myTable" border="1">
7
<tr>
8
<td>cell 1</td>
9
<td>cell 2</td>
10
</tr>
11
<tr>
12
<td>cell 3</td>
13
<td>cell 4</td>
14
</tr>
15
</table>
16
<br>
17
<button type="button" onclick="displayResult()">显示第一行单元格的数量</button>
18