<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="javascript">
function Add() {
var temp=document.getElementsByName("sss")[0];
temp.insertRow(temp.rows.length);
temp.rows.item(temp.rows.length-1).insertCell(0);
var xx=temp.rows.length-1;//-1
var sHTML;
sHTML='姓名:<input name="name" type="text"><input type="button" value="删除" onclick="Delete(this);">';
temp.rows.item(temp.rows.length-1).cells.item(0).innerHTML=sHTML;
temp.rows.item(temp.rows.length-1).cells.item(0).children.item(1).text =xx;
}
function Delete(x){
var temp=document.getElementsByName("sss")[0];
temp.deleteRow(x);
for(var j=1;j<temp.rows.length;j++)
temp.rows.item(temp.rows.length-1).cells.item(0).children.item(1).text=j;
}
</script>
</HEAD>
<BODY>
<table id="table1">
<tr>
<input type="button" value="添加" onClick="Add();" />
<td>姓名:<input name="name" type="text"></td><br>
</tr>
</table>
<TABLE name="table2" align="center" id="sss">
<TR>
</TR>
</TABLE>
</BODY>
</HTML>
仿163的添加删除附件例子
最新推荐文章于 2020-07-30 19:06:39 发布