<!DOCTYPE html>
<html>
<head>
<meta charset=
"UTF-8"
>
<title></title>
<style type=
"text/css"
>
#box{
margin:0 auto;
background:yellow;
border:4px double #808080;
width:600px;
text-align:center;
}
#box input{
width:130px;
}
#box table{
margin:5px 0;
background:lawngreen;
}
</style>
<script type=
"text/javascript"
>
onload =
function
(){
var
aInput = document.getElementsByTagName(
'input'
);
var
bTn = document.getElementById(
'btn'
);
var
table = document.getElementsByTagName(
'table'
)[0];
bTn.onclick =
function
(){
var
oTr=document.createElement(
'tr'
);
table.appendChild(oTr);
for
(
var
i = 0; i < aInput.length-1; i ++){
var
oTd=document.createElement(
'td'
);
oTd.innerHTML=aInput[i].value;
oTr.appendChild(oTd);
}
var
oTd=document.createElement(
'td'
) ;
oTd.innerHTML=
'<a href="javascript:;" rel="external nofollow" rel="external nofollow" >删除</a>'
;
oTr.appendChild(oTd);
oTd.getElementsByTagName(
'a'
)[0].onclick=
function
(){
table.deleteRow(1);
}
}
}
</script>
</head>
<body>
<div id=
"box"
>
ID:<input type=
"text"
name=
""
id=
""
value=
""
/>
姓名:<input type=
"text"
name=
""
id=
""
value=
""
/>
电话:<input type=
"text"
name=
""
id=
""
value=
""
/>
<input type=
"button"
name=
"btn"
id=
"btn"
value=
"保存"
style=
"width:50px;"
/>
<table border=
""
cellspacing=
""
cellpadding=
""
width=
"600px"
>
<tr>
<td>Id</td>
<td>name</td>
<td>tal</td>
<td>操作</td>
</tr>
</table>
</div>
</body>
</html>