<HTML>
<HEAD>
<TITLE>New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script type="text/javascript">
/*
*增加模板行
*/
function addRow() {
var table = document.getElementById("addTable")
var tbody = document.getElementById("templeteTBody")
var newTBody = tbody.cloneNode(true)
newTBody.style.display=""
var footTBody = document.getElementById("footTbody")
return table.insertBefore(newTBody,footTBody)
}
/*
*删除模板行
*/
function deleteRow(obj) {
var tbody = obj.parentNode.parentNode.parentNode
var table = document.getElementById("addTable")
table.removeChild(tbody)
}
/**
*向模板中填充值
*/
function setValue(){
var tbody=addRow()
}
</script>
<BODY>
//页面代码
<input type="button" value="增加" onclick="setValue()">
<table id="addTable">
<tbody id="templeteTBody" style="display: none">
<tr>
<td><input type="button" value="删除" onclick="deleteRow(this)"/></td>
<td>a</td>
<td><input type="text" /></td>
<td>b</td>
<td><input type="text" /></td>
</tr>
</tbody>
<tbody id="footTbody">
</tbody>
</table>
</BODY>
</HTML>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)