document.createElement in IE with TR tag

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rain_c1@web.de

    document.createElement in IE with TR tag

    Hi!

    I have problems with document.create Element() in IE when using TR tags.
    Please look at the following very short example:

    ------------snip-----------------
    <table id="test"></table>

    <script type="text/javascript">
    var MyTable = document.getEle mentById("test" );
    var myTR = document.create Element('tr');
    var myTD = document.create Element('td');
    var myText = document.create TextNode("this is text");

    myTD.appendChil d(myText);
    myTR.appendChil d(myTD);
    MyTable.appendC hild(myTR);
    </script>
    ------------snip-----------------

    this works fine in Firefox, but IE is very strange. It refuses to
    display the created elements. Through further tests I realized, that
    only the TR tag is the problem. If this is already in the static HTML
    code it works in IE, too.

    Further very strange: If I use the developer toolbar for IE and use the
    DOM Explorer, it shows me, that all my dynamic generated tags are
    there, but they are not displayed.

    Has anybody an idea?

    Thank you very much!

    Best regards,
    - Rainer

  • Matt Kruse

    #2
    Re: document.create Element in IE with TR tag

    rain_c1@web.de wrote:[color=blue]
    > var MyTable = document.getEle mentById("test" );[/color]

    Get a reference to the tbody element instead of the table element.
    When you don't explicitly put one in, IE puts one in for you.
    A TR can only be appended to a tbody.

    --
    Matt Kruse




    Comment

    • rain_c1@web.de

      #3
      Re: document.create Element in IE with TR tag

      this works very fine, thanks a lot!

      Comment

      Working...