A d3.select… equivalent to jQuery.children()

后端 未结 5 1758
感动是毒
感动是毒 2021-01-07 21:03

I\'m using d3 to append some elements on enter() and then update them later. However, the next time i try to select those elements the selection is much larger than the orig

5条回答
  •  隐瞒了意图╮
    2021-01-07 21:27

    Here is a much better way to do it:

    var parent = d3.selectAll(".myParentClass");
    parent.each(function(d,i) {            
       var children = d3.selectAll(this.childNodes);
       console.log(children);
    });
    

    This way you don't need to unnecessarily add classes to what could be 100's of (or even more) child nodes.

提交回复
热议问题