Simple html:
<div class="div1">
<div class="test"><span>1</span></div>
<div class="test"><span>2</span></div>
</div>
And js:
var el = d3.select(".div1").selectAll(".test");
el.each(function() {
console.log(arguments);
});
Output:
[undefined, 0, 0]
[undefined, 1, 0]
What is the latest argument (0)? According to source code this is group, but I can’t find anything about selector groups in d3 documentation.
Thanks.
It’s for nested selectors:
http://bost.ocks.org/mike/nest/
e.g. for this HTML:
Let’s select td:
el is
[Array[2]
,
Array[2]
]
and
el.each:Output: