This animation demonstrates how selection.selectAll works: every element in the old selection becomes a group in the new selection. Here, an initial selection of table rows is then used to create a selection of table cells:
d3.selectAll("tr").selectAll("td");
The result is a selection of table cells (td elements) grouped by their table row.
https://d3js.org/d3.v3.min.js