Add to a table with javascript

Posted by incrediman on Stack Overflow See other posts from Stack Overflow or by incrediman
Published on 2010-03-19T19:00:30Z Indexed on 2010/03/19 19:11 UTC
Read the original article Hit count: 176

I have a table which looks like this:

<table id='t'>
    <thead>
        ....
    </thead>
    <tbody id='t_tbody'>
    </tbody>
</table>
  • thead is filled with content

  • tbody is empty

I want to use javascript to add this (for example) to t_tbody:

<tr>
    <td>Name</td>
    <td>Points</td>
    <td>Information</td>
</tr>

How can I do this? I need a function which adds the above to t_tbody.

Note that simply using

document.getElementById('t_tbody').innerHtml+="<tr>...</tr>"

works fine in FF, but not in IE.

Also note that I need to use raw javascript (ie. no frameworks) for this project, as I am finishing a project which has already been mostly completed using raw javascript.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about table