我正在使用D3.js。这是我的标记:
<div class="graph-container">
<!--Graph SVG-->
</div>
<div class="graph-container">
<!--Graph SVG-->
</div>
<div>
<!--some other SVG-->
</div>
我使用以下 JS 来删除所有 SVG 元素:
d3.selectAll("svg > *").remove();
但我只想删除 graph-container 类中存在的 SVG。我怎样才能做到这一点?
最佳答案
d3.selectAll('.graph-container svg').remove();
关于javascript - 如何删除div内的svg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31591302/