这里是以前篇附件上传为前提,比较原始的一种方式,但最容易修改
function addfile(){
var aElement = document.getElementById("usertable");
var dd = document.createElement("tr");
var tdobj=document.createElement("td");
tdobj.innerText="请上传附件";
dd.appendChild(tdobj);
var tdobj3=document.createElement("td");
tdobj3.setAttribute("colspan", "2");
var inp2 = document.createElement("input");
inp2.setAttribute("type", "file");
inp2.setAttribute("name", "file");
tdobj3.appendChild(inp2);
dd.appendChild(tdobj3);
var tdobj4=document.createElement("td");
var sp=document.createElement("a");
sp.setAttribute("title", "删除该附件");
if(sp.addEventListener)
{
sp.addEventListener("click", function(){deteFile123(sp);},false);
}
else if(sp.attachEvent)//IE内核监听
{
sp.attachEvent("onclick", function(){deteFile123(sp);});
}
else
{
sp.click = function(){deteFile123(sp);};
}
var ff = document.createElement("span");
ff.innerText="删除附件";
sp.appendChild(ff);
tdobj4.appendChild(sp);
dd.appendChild(tdobj4);
aElement.appendChild(dd);
}
//删除附件
function deteFile123(obj){
//alert(id);
var aElement = document.getElementById("usertable");
obj = obj.parentNode.parentNode;
aElement.removeChild(obj);
}