In HTML, I can clear a Is there an equivalent if I have an div.innerHTML = \"\";
You can use the clone and replace the element with the cloned one.
var parentElement = svg.parentElement
var emptySvg = svg.cloneNode(false);
parentElement.removeChild(svg);
parentElement.appendChild(emptySvg);
This will append the svg at the end, you might want to get the element before and append accordinaly