Kevin Smith <Ke*********@sas.com> writes:
I want to take a document that contains a number of tables and wrap the
tables inside new elements. I have tried something similar to the
following:
tparent = table.parentNode;
wrapper = document.createElement('DIV');
wrapper.appendChild(table);
A DOM node can only have one parent. At this point, you *move* the
table into the wrapper ...
tparent.replaceChild(wrapper,table);
.... so it is no longer a child of tparent.
Try switching the operations:
tparent = table.parentNode;
wrapper = document.createElement('DIV');
tparent.replaceChild(wrapper,table);
wrapper.appendChild(table);
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'