D3.js selection.remove()函数
selection.remove()函数用于从文档中删除选定的元素,并返回一个带有已删除元素的新选择。此外,新的选择现在与 DOM 分离
句法:
selection.remove();
参数:此函数不接受任何参数。
返回值:此函数返回一个新的选择。
示例 1:
HTML
GeeksforGeeks
D3.js selection.remove() Function
The divs will be removed.
1. This div will be removed.
2. This div will be removed.
HTML
Geeks for geeks
D3.js selection.remove() Function
The from div will be removed.
1. This text will be removed.
2. This div will not be removed.
输出:
在点击“点击这里!”之前元素:
点击“点击这里!”后元素:
示例 2:
HTML
Geeks for geeks
D3.js selection.remove() Function
The from div will be removed.
1. This text will be removed.
2. This div will not be removed.
输出:
在单击单击此处按钮之前:
单击单击此处按钮后: