...

View Full Version : appendChild under IE



Jojorax
03-29-2004, 03:53 PM
Following code works fine under Mozilla 1.6 but not under IE6; it doesn't produce errors, but the appendChild method seems to be completely ignored.
Can someone explain me the reason/solution? Thanks



<html><head>

<script>

function test()
{
var tbl = document.getElementById("testTable");
var trElm = document.getElementById("testTr");
var newTr = trElm.cloneNode(true);
tbl.appendChild(newTr);
}

</script></head>

<body>

<table border="1" id="testTable" name="testTable">

<tr id="testTr" name="testTr">
<td>Item1</td>
<td>Item2</td>
<td>Item3</td>
</tr>

</table>

<input type="button" onclick="javascript:test()" value="Test">

</body></html>

liorean
03-29-2004, 04:13 PM
You need to append the trs to the tbody, instead of directly under the table.

sad69
03-29-2004, 07:11 PM
This is a very common problem. I think we should put it as a sticky or an FAQ or something, but also it should be more explicit in tutorials, etc..

Sadiq.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum