IE appendChild problem solved

Today my boss ran into a problem using the internal CMS I’ve written for work. After seeing him demonstrate the problem, I figured it was probably an IE issue. Of course, my boss and manager laughed, since my answer to many bugs they find is that it’s an IE issue.

Turned out it was, though.

Luckily, with a little bit of Google searching, I came across this post on the SitePoint forums.

My problem was that I was creating a new tr element and then adding it directly to my table element. But what IE does is create an implicit tbody element as a child of the table (and parent to the tr elements). So I was adding my row to the wrong parent. It worked fine on Firefox, but nothing was happening in IE.

Luckily, it was a simple fix! All I had to do is put in my own tbody in the table, and add the tr to that.

25 Responses to “IE appendChild problem solved”

  1. Treena Says:

    thank you so much for posting this information. I am not sure how long it would have taken me to figure this out :-)

  2. Yanni Says:

    I could not tell you how much I love you.
    Thanks for your information (and Google of course, lol).
    I’ve been nagged by this problem few days.
    Many thanks!

  3. Joe Says:

    Well there’s an hour of my life I will never get back, but — if not for this post — it could have been a week. Thank you!

  4. Maarten Says:

    Hah, yes, thank you and google! :)

  5. Mr. Tips Says:

    YEEEEEEEHA!!! Thanks!

  6. Faiz Says:

    Thank you very much indeed!

  7. Stefan Says:

    Thank you very much, this post solved my problem!

  8. Thomas Says:

    Vielen Dank für die Lösung! ich habe viele Stunden mit diesem Problem gekämpft!
    danke

  9. Dima Says:

    Thaaaank you!!!!

  10. Matej Balantic Says:

    Thank you VERY much for your help! I spent few hours on solving this problem, before I read this post!

    Best regards!
    Matej

  11. wifi Says:

    thanks for the post, saved my night :D

    now i can sleep peacefully!!!!

    burn IE. Firefox to the power!!!

  12. Derek Says:

    Thanks a million, saved me lots of time :)

  13. eoin Says:

    Thanks for this.. been trying to figure this out these last few hours.. it was driving me nuts!.. thanks again..

  14. Jonny Says:

    Ho. Ly. Shit.
    I spent the past two hours trying to figure this out. God bless you! God damn IE!

  15. benny Says:

    Thank you!!!
    IE is shit

  16. Ed Says:

    THANK YOU!

  17. Joe Says:

    Top search result for “IE appendchild.” Thank god, because I fully expected to spend the next 4 hours trying to figure this out. THANKS!

  18. Chris Says:

    As everyone else has said: thanks! This info totally helped me out.

  19. peter Says:

    I can’t thank you enough for this…

  20. Lari Says:

    Hey,
    thank you very, very, very much!
    This post totally saved my day! :D

  21. George Says:

    I’m dynamically creating elements all the time, and this is the first time I’ve run into this problem - thanks very much!

  22. Alex Boia Says:

    Very useful information…this post just spared my keyboard from an unnecessary pain…;))

  23. Alex Boia Says:

    PS: This works in mozilla because mozilla appends rows by default to the tbody…firebug shows this clearly

  24. Jack Rose Says:

    Jennifer gets a star in her crown!

    Don’t you just LOVE the way your Jscript code fails silently with NO indication of what you did wrong.

    Bill Gates owes me a sushi dinner for this.

    “Professor” Jack

  25. Oliver Says:

    excellent article; saved me a lot of time. this damn thing made my browser crash instantly.