Jump to content

saila.com

Online media matters

Why doesn’t Internet Explorer add a table using appendChild?

Adding a table using the DOM is relatively easy — all you need to do is dynamically create the needed TD (and/or TH), TR, TBODY (and/or TFOOT and/or THEAD), and TABLE nodes using createElement. The you add each child to its parent using appendChild.

If, however, it’s not being rendered by Internet Explorer (although it appears in other browsers or by displaying innerHTML), you’ve likely forgotten one element: either TBODY, TFOOT, or THEAD. Create one of those elements, and append the rows to it. Then, add that node to the table, and Internet Explorer should render it properly.