I'd like to use JavaScript to add rows to a table. It seems like an easy idea, but it occurs to me that the parent node of the rows might technically be a TBODY element. So, I'm wondering if I use appendChild to add a table row to a table element am I doing something wrong and, more importantly, is it going to fail in browser x?
For example:
function addTheRow() {
var myTable = document.getElementById('myTable');
var newRow = document.createElement('TR');
var newCell = document.createElement('TD');
newCell.appendChild( document.createTextNode('Yeah, Baby! Yeah!!') );
newRow.appendChild( newCell );
myTable.appendChild( newRow );
} // End addTheRow function
Should I do something to identify the TBODY element and add the element to that instead?
Thank you.
--
-- Ghodmode