It is quite common that you will need to perform scoped selection when working on visualization. For example, selecting all div
elements within a particular section
element is one such use case of scoped selection. In this recipe, we will demonstrate how this can be achieved with different approaches and their advantages and disadvantages.
Open your local copy of the following file in your web browser:
https://github.com/NickQiZhu/d3-cookbook-v2/blob/master/src/chapter2/sub-selection.html .