我试过了:</p>
<table id ="table1">
<tr id ="aa"><td>aa</td></tr>
<tr id ="bb"><td>bb</td></tr>
</table>
<input type="button" onclick = "test()" value = "button">
和javascript:</p>
function test(){
var parent=document.getElementById("table1");
var child=document.getElementById("aa");
parent.removeChild(child); //this isn't work
//child.parentNode.removeChild(child); this is ok!
}
错误:
未捕获的 NotFoundError:尝试在不存在的上下文中引用节点
因此,我怀疑,table 不是 tr 的父级吗?