user3074097
user3074097

Reputation: 817

How to remove nested elements in d3.js

I have an HTML structure like this

body
  svg
     g
      path d
      circle  (class=circles)
     g
      path d
      circle  (class=circles)
     g
     path d
     g
     path d
     g
      path d
      circle (class=circles)

I want to remove all circles from body->svg->g->circle with class=circles . Some "g" tags have circles with class as "circles".

Please guide me how to do this.

Upvotes: 1

Views: 463

Answers (1)

Lars Kotthoff
Lars Kotthoff

Reputation: 109232

You can do this in one line using a DOM selector:

d3.selectAll("circle.circles").remove();

Upvotes: 1

Related Questions