<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>dom邮件附件</title>
<style type="text/css">
div{
border:1px solid;
width:300px;
}
</style>
</head>
<body>
<input id="file" type="file" />
<input type="button" value="添加上传" onclick="getUpInfo()"/>
<input type="button" value="删除上传" onclick="delUpInfo()" />
<div id="upload"></div>
</body>
</html>
<script type="text/javascript" language="javascript">
//创建表格
var table=document.createElement("table");
function getUpInfo(){
var info=document.getElementById("file").value;
addUpInfo(info);
}
function addUpInfo(info){
//创建tr
var tr=document.createElement("tr");
//创建td
var td=document.createElement("td");
//创建text
var text=document.createTextNode(info);
td.appendChild(text);
tr.appendChild(td);
/* var button=document.createElement("button");
var atext=document.createTextNode("删除");
button.appendChild(atext);
td.appendChild(button);
tr.appendChild(td);*/
table.appendChild(tr);
document.getElementById("upload").appendChild(table);
}
function delUpInfo(){
var tr=document.getElementsByTagName("tr");
var table=tr[0].parentNode;
table.removeChild(tr[tr.length-1]);
}
</script>