title: How do I clone an element or chunk of dom?
body: <p>I have been trying to create a beautiful tree with D3.</p>
  
  <p>And for the nodes I have a SVG "template" in a hidden div. But I have been trying with many functions of D3 to "clone" the "template" but all didn't run.</p>
  
  <p>The last javascript code is:</p>
  
  <pre><code>...
  var node = svg.selectAll("g.node")
              .data(nodes)
              .enter()
              .append("svg:g")
              .attr("transform",
                      function(d)
                      {
                          return "translate(" + d.y + "," + d.x + ")";
                      }
              );
  
  var template_box = d3.select("#layer1");
  console.log(template_box);
  
  node.insert(template_box);
  ...
  </code></pre>
  
  <p>And the chuck of html is:</p>
  
  <pre><code>...
      &lt;body&gt;
   &lt;svg width="400" height="400"&gt;
   &lt;g
   id="layer1"
   transform="translate(-208.375,-410.5)"&gt;
  &lt;rect
  ...
  </code></pre>
  
  <p>Regards.</p>