In HTML, it's very convenient to be able to say:
div.innerHTML = "";
In order to clear a <div>
element.
Is there any equivalent if I have an <svg>
element instead? There seems to be neither innerHTML
nor innerXML
or even innerSVG
.
I know the SVG DOM is a superset of the XML DOM, so I know I can do something like this:
while (svg.lastChild) {
svg.removeChild(svg.lastChild);
}
But this is both tedious and less performant. So just curious, does anyone know of any faster or easier way to clear an SVG element?