admin管理员组

文章数量:1303345

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.

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.

Share Improve this question asked May 12, 2014 at 4:40 jetstreaminjetstreamin 4175 silver badges19 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

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")

本文标签: javascriptD3 Selecting all elements having a certain class or combination of classesStack Overflow