How to save DOM references of elements whose parent innerHTML property was
set to empty string (in IE)
In IE, when one sets the innerHTML property of a DOM element, this
automatically empties the innerHTML property all the child references. How
can I keep the child in memory in order to be able to clone it later and
append it to the parent?
Example HTML:
<div id="parent">
<div id="child">
</div>
</div>
script:
var parent = document.querySelector('#parent', document);
var child = document.querySelector('#child', parent);
parent.innerHTML = '';
// at this point child.innerHTML is ALSO empty!!!
// I want to clone later the child back into the parent
How can I keep the child in memory? Is child.outerHTML the only solution?
PS: in IE (up to 10), no jQuery
No comments:
Post a Comment