Mahomedalid
simplemente la vida ... mahomedalid feed
revista urbana y cultural de tepic
Mostrando las entradas con la etiqueta internet explorer es una mierda. Mostrar todas las entradas
Mostrando las entradas con la etiqueta internet explorer es una mierda. Mostrar todas las entradas

miércoles, julio 01, 2009

Replacing the innerHTML of a table/tbody

There are some DOM Objects that IE doesn't permit to change the innerHTML; ej. tbody, tables and tr's.

That really sucks, because the first option it's create all the tr's by hand. Guess what, I have a little workaround that maybe can help you.


var changeInnerHTMLOfMyCuteTbodyById = function (id_tbody, inner_html)
{
//preparing
var my_tbody = document.getElementById (id_tbody);
var my_table = my_tbody.parentNode;

my_table.removeChild (my_tbody);

//creating dom tree
var html = '<table style=\'display:none;\'><tbody id='+ id_tbody+'>' +
inner_html + '</tbody></table>';

var tmp_div = document.createElement ('div');

tmp_div.innerHTML = html;

document.body.appendChild (tmp_div);

//moving the tbody
my_table.appendChild (document.getElementById (id_tbody));
}