[急]如何删除所有的Table子节点(tr,td)
我知道可以用innerHTML= ' ';但是FF没有这个属性,所以要通过XML的方法删除但是childnode好象没有remove的方法怎么删除?
------解决方案-------------------- <html>
<head>
<title> </title>
<script language= "JavaScript ">
window.onload = function()
{
T();
}
function T()
{
var t = document.getElementById( "tab ");
if(t.rows.length > 0)
{
t.deleteRow(0);
setTimeout( "T() ", 1000);
}
}
</script>
</head>
<body>
<TABLE id= "tab " border= "1 ">
<TR> <TD> 1 </TD> <TD> 2 </TD> <TD> 3 </TD> <TD> 4 </TD> </TR>
<TR> <TD> 5 </TD> <TD> 6 </TD> <TD> 7 </TD> <TD> 8 </TD> </TR>
<TR> <TD> 9 </TD> <TD> 10 </TD> <TD> 11 </TD> <TD> 12 </TD> </TR>
<TR> <TD> 13 </TD> <TD> 14 </TD> <TD> 15 </TD> <TD> 16 </TD> </TR>
</TABLE>
</body>
</html>
------解决方案--------------------for(i = document.getElementById( "table1 ").rows.length-1;i> -1;i--)
document.getElementById( "table1 ").deleteRow(i)