刪除不了,Error哪里?
<script type="text/javascript">
window.onload=function(){
var oTab=document.getElementById("table");
var oTr=oTab.getElementsByTagName("tr");
//變色
for(var i=0;i<oTr.length;i++){
oTr[i].onmouseover=function(){
this.style.backgroundColor="#f2f2f2";
}
oTr[i].onmouseout=function(){
this.style.backgroundColor="#fff";
}
}
//添加一行
var oBtn=document.getElementsByTagName("input")[0];
oBtn.onclick=function(){
var oTrNew=document.createElement("tr");
var oTdNew1=document.createElement("td");
var oTdNew2=document.createElement("td");
var oTdNew3=document.createElement("td");
oTab.appendChild(oTrNew);
oTrNew.appendChild(oTdNew1);
oTrNew.appendChild(oTdNew2);
oTrNew.appendChild(oTdNew3);
oTdNew1.innerHTML="xh003";
oTdNew2.innerHTML="Ajax";
oTdNew3.innerHTML="<a href='javascript:;'>刪除</a>";
}
//刪除當(dāng)前行
var aA=oTab.getElementsByTagName("a");
for(var i=0;i<aA.length;i++){
aA[i].onclick=function(){
var oTrA=this.parentNode.parentNode;
oTab.parentNode.removeChild(oTrA);
}
}
}
</script>
2015-04-13
你看一下右下方的源碼下載吧,你的代碼。。。。然后你把前面的一些基礎(chǔ)再重新過一下吧