Jump to content

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


Scribe
 Share

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

Edited by Scribe
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...