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

前端 未结 9 1067
误落风尘
误落风尘 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:46

    If you're using jQuery, you can just do

    $("#svgid").empty();
    

    This deletes all child elements of the svg while leaving its other attributes like width and height intact.

提交回复
热议问题