D3.js selection.merge()函数
d3.js 中的selection.merge()函数用于将两个给定的选择合并为一个,并在合并后返回新的选择。返回的选择与此选择具有相同数量的组和相同的父项。
句法:
selection.merge(other);
参数:此函数接受描述要合并的选择的其他单个参数。
返回值:此函数返回一个选择。
示例 1:
HTML
1. This text is in bold
2. This text is also in bold
3. Geeks
4. Geeks
5. Geeks for geeks
HTML
1. This is odd
2. This is even
3. This is odd
4. This is even
5. This is odd
输出:
示例 2:
HTML
1. This is odd
2. This is even
3. This is odd
4. This is even
5. This is odd
输出: