JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<svg>
<g><path d='m10,10l10,0,0,-10,-10,0'></path></g>
</svg>
</div>
JavaScript
g = $("svg g").clone();
console.log(g);
$('svg').append(g);
// Move the cloned square
g.children().first().attr('d', 'm100,100l10,0,0,-10,-10,0');
var s = new XMLSerializer();
var str = s.serializeToString(g[0]);
console.log(str);