x
1
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<title>蜜蜂教程(mifengjc.com)</title>
6
<script>
7
function insRow() {
8
var x = document.getElementById('myTable').insertRow(0);
9
var y = x.insertCell(0);
10
var z = x.insertCell(1);
11
y.innerHTML = "新单元格1";
12
z.innerHTML = "新单元格2";
13
}
14
</script>
15
</head>
16
17
<body>
18
<table id="myTable" border="1">
19
<tr>
20
<td>行1 列1</td>
21
<td>行1 列2</td>
22
</tr>
23
<tr>
24
<td>行2 列1</td>
25
<td>行2列2</td>
26
</tr>
27
<tr>
28
<td>行3 列1</td>
29
<td>行3 列2</td>
30
</tr>
31
</table>
32
<br>
33
<input type="button" onclick="insRow()" value="插入行">
34
35
</body>
36
</html>