请教,ie与firefox下节点操作的问题。
点button1,ie下alert出是2,firefox下alert出是3,为什么是这样的结果呢?向各位请教了!
<script language="javascript">
function msg()
{
alert(document.getElementById("id_5").childNodes.length)
}
</script>
<table id="mytable" width="200" border="0" align="center" cellspacing=1 cellpadding=2 >
<tr class=header>
<td> aa </td>
</tr>
<tr>
<td>
<input type="text" name="address" size="40" value="beijing" />
</td>
<tr class=header>
<td> bbb </td>
</tr>
<tr>
<td>
<input type="button" id="button1" value="click" onclick='msg();' />
</td>
</tr>
<tr>
<td id="id_5">
<input type="button" value="button"/>
</td>
</tr>
</table>
------解决方案--------------------楼主再试下 ,知道什么原因了吧 ,空格 以及 换行 的问题
HTML code
<script language="javascript">
function msg()
{
alert(document.getElementById("id_5").childNodes.length)
}
</script>
<table id="mytable" width="200" border="0" align="center" cellspacing=1 cellpadding=2 >
<tr class=header>
<td> aa </td>
</tr>
<tr>
<td>
<input type="text" name="address" size="40" value="beijing" />
</td>
<tr class=header>
<td> bbb </td>
</tr>
<tr>
<td>
<input type="button" id="button1" value="click" onclick='msg();' />
</td>
</tr>
<tr>
<td id="id_5"><input type="button" value="button" /></td>
</tr>
</table>