Scribe Posted April 8, 2010 Share Posted April 8, 2010 Hi guys,A pretty annoying issue I'm having here in IE 6 and 7 only. Was wondering if anyone has any fix suggestions? var editTableHead = resultTable.tHead.cloneNode( true ); alert( resultTable.tHead.rows[0].cells.length ); alert( editTableHead.rows[0].cells.length ); Simply enough, although cloneNode() is working and the innerHTML has been copied, the rows[] array seems to have not been copied and the second alert throws a null object error.Any ideas how I can correctly clone a tHead object to preserve the rows[] array?Many thanks Link to comment Share on other sites More sharing options...
Scribe Posted April 8, 2010 Author Share Posted April 8, 2010 OK! Sorted,You have to add the cloned tHead element to a table element before IE reconstructs the rows[] array.Many thanks Link to comment Share on other sites More sharing options...
jeffman Posted April 8, 2010 Share Posted April 8, 2010 FWIW, tables often create unexpected problems.For example, the HTML for a table may not explicitly create a <tbody> element. But a browser might add a <tbody> to the DOM anyway. Knowing this can help you understand problems that might come up with parent-child relationships. (Solution: explicitly add a <tbody> element to your HTML.)Then there is the whole matter of using innerHTML to manipulate tables. Sometimes works, sometimes doesn't. Solution: only use it to add content to a <td> element. For the rest, use methods like addRow().I'm sure there are others. The lesson is not to take things for granted. (select elements are likewise problematic.) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.