为什么TABLE通过 DATASRC 绑定一个XML 文件后,无法删除TABLE 中的TR 对象???
为什么TABLE通过 DATASRC 绑定一个XML后,无法删除TABLE 中的TR 对象?
请高手解释一下!!!
整个HTML 文件如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<xml id= 'globalDoc ' >
<root>
<info>
<id> 882 </id>
<datepart> 07071 </datepart>
<firstNumber> 9 </firstNumber>
<secondNumber> 8 </secondNumber>
<thirdNumber> 4 </thirdNumber>
<fullNumber> 984 </fullNumber>
<totalNumber> 21 </totalNumber>
</info>
<info>
<id> 881 </id>
<datepart> 07070 </datepart>
<firstNumber> 4 </firstNumber>
<secondNumber> 4 </secondNumber>
<thirdNumber> 1 </thirdNumber>
<fullNumber> 441 </fullNumber>
<totalNumber> 9 </totalNumber>
</info>
</root>
</xml>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
function fnClearTable()
{
var table = document.getElementById( "tableOne ");
try
{
for(var i=table.rows.length-1;i> =1;i--)
{
table.deleteRow(i);
}
}catch(e)
{
alert(e.name+e.message);
}
}
</script>
</HEAD>
<BODY>
<table width= "100% " datasrc= '#globalDoc ' id= 'tableOne ' border= "0 " cellpadding= "3 " cellspacing= "1 " bgcolor= "DDDEC8 ">
<thead align= "middle " bgcolor= "FAFAF1 ">
<th> <div align= "center "> 期数 </div> </th>
<th> <div align= "center "> 号码 </div> </th>
<th> <div align= "center "> 和数 </div> </th>
</thead>
<tbody>
<tr>
<td> <div align= "center " dataFld= 'datepart '> </td>
<td> <div align= "center " dataFld= 'fullNumber '> </td>
<td> <div align= "center " dataFld= 'totalNumber '> </td>
</tr>
</tbody>
</table>
</BODY>
</HTML>
<script>
fnClearTable();
</script>
------解决方案-------------------- <script>
function fnClearTable()
{
var table = document.getElementById( "tableOne ");
try
{
for(var i=table.rows.length-1;i> =1;i--)
{
table.rows[i].removeNode(true);
}
}catch(e)
{
alert(e.name+e.message);
}
}
</script>
------解决方案--------------------个人认为deleteRow应该是要把