我的动态添加表格的一行

<html>
<head>
</head>
<script>
var row_times = 3;
function add_tr(){
	var atable = document.getElementById("atable");
	var atr = document.createElement("tr");
	atr.border="1";
	var atd = document.createElement("td");
	atd.border="1";
	atd.height="30";
	var anode = document.createTextNode("第" + row_times++ +"行");
	atd.appendChild(anode);
	atr.appendChild(atd) ;
	atable.appendChild(atr) ;
}
</script>
<body>
<form>
<table id="atable" name="atable" border="1" width="98%">
<tr><td><input type="button" value="添加一行" onclick="javascript:add_tr();"</td></tr>
<tr>
<td>第一行</td>
</tr>
<tr>
<td>第二行</td>
</tr>
</table>
</form>
</body>
</html>

你可能感兴趣的:(JavaScript,jquery,浏览器,IE,firefox)