删除不了,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>";
}
//删除当前行
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>