I am trying to insert into a DOM element the content of a document fragment (in pure javascript). The working principle is this:
var a = document.getElementById("a"),
b = document.getElementById("b");
now i place the content of "a" into a document fragment, using a template element
var content = document.createElement("template");
content.innerHTML = a.innerHTML;
content = content.content.cloneNode(true);
now i would like to replace the content of b
with the content of content
. I tried with a simple b.innerHTML = content.innerHTML;
, but it seems like if document fragments doesn't have innerHTML
property.
Is this possible to do?
Note: i know this is totally an ineffective way to do the task of making b.innerHTML = a.innerHTML
, but obviously this is just a simplification of a bigger task i am managing to do.