Jump to content

Fix for odd IE 6/7 cloneNode() behaviour?


Scribe

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...