Is there an easy way to clear an SVG element's contents?

前端 未结 9 1255
误落风尘
误落风尘 2020-12-29 01:14

In HTML, I can clear a

element with this command:

div.innerHTML = \"\";

Is there an equivalent if I have an

9条回答
  •  没有蜡笔的小新
    2020-12-29 01:43

    element = document.getElementById("elementID");
    element.parentNode.removeChild(element);
    

    I got the idea from http://www.carto.net/svg/manipulating_svg_with_dom_ecmascript/

提交回复
热议问题