sun_haha
2014-12-28 20:33
function addtr(){
var oldnode=document.getElementById("table").lastChild;
var newtr=createElement("tr");
var newtdsn=createElement("td");
var sn=prompt("输入学号","h001");
newtdsn.innerHTML=sn;
var newtdname=createElement("td");
var name=prompt("输入姓名","王小明");
newtdname.innerHTML=name;
var newtdoperation=createElement("td");
var newhref=createElement("a");
a.setAttribute("href","javascript:");
a.setAttribute("onclick","deletetr(this)");
a.innerHTML="删除";
oldnode.appendChild(newtr);
newtr.appendChild(newtdsn);
newtr.appendChild(newtdname);
newtr.appendChild(newtdoperation);
newtdoperation.appendChild(newa);
}
终于知道哪错了
function addtr(){
var oldnode=document.getElementById('table').lastChild;
var newtr=document.createElement("tr");
var newtdsn=document.createElement("td");
var sn=prompt("输入学号","h001");
newtdsn.innerHTML=sn;
newtr.appendChild(newtdsn);
var newtdname=document.createElement("td");
var name=prompt("输入姓名","王小明");
newtdname.innerHTML=name;
newtr.appendChild(newtdname);
var newtdoperation=document.createElement("td");
newtr.appendChild(newtdoperation);
var newhref=document.createElement("a");
newhref.setAttribute("href","javascript:");
newhref.setAttribute("onclick","deletetr(this)");
newhref.innerHTML="删除";
newtdoperation.appendChild(newhref);
oldnode.appendChild(newtr);
}
JavaScript进阶篇
468194 学习 · 21891 问题
相似问题
回答 2
回答 1