문제

I am using D3 and I want to select all elements on the page that have a certain class. I have tried:

    d3.selectAll("body").attr("body", "symbol-clicked");


but this assigns the class symbol-clicked to all elements on the page. I just want a collection of group of elements that already have the symbol-clicked class so I can change it to just symbol.

Any help is greatly appreciated.

도움이 되었습니까?

해결책

Use

  d3.select("body").selectAll(".className")

This will give you all the elements with the class 'className'.

To get elements with multiple classes. Try

 d3.select("body").selectAll(".className1").filter(".className2")
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top