<head>
<title>Untitled Document</title>
<script>
function addRow()
{
var table = document.getElementById("t")
var tr = table.insertRow()
var td1 = tr.insertCell()
var input1 = document.createElement("input")
input1.name = "a"
input1.value = "a"
td1.appendChild(input1)
var td2 = tr.insertCell()
var input2 = document.createElement("input")
input2.name = "b"
input2.value = "b"
td2.appendChild(input2)
var td3 = tr.insertCell()
var input3 = document.createElement("input")
input3.name = "c"
input3.value = "c"
td3.appendChild(input3)
tr.ondblclick = function()
{
tr.parentNode.removeChild(tr)
}
}
</script>
</head>
<body>
<table id="t" border="1">
</table><br>
<input type="button" value="addRow" onclick="addRow()"/>
</body>
</html>
给你参考下
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)