Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2004
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    appendChild under IE

    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

    Code:
    <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>

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    You need to append the trs to the tbody, instead of directly under the table.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •