Deleting dom with D3 fails Hello everyone. I try to use D3 to manipulate doms, which are defined in html ahead of time. Content in html:
<div>
<p class="child" id="1">James</p>
<p class="child" id="2">Kate</p>
D3 code:
var div = d3.select('div')
var pp = div.selectAll('p.child');
var ppUpdate = pp.data(dataset, d =>d.id);
var ppexit = ppUpdate.exit();
ppexit.remove();
I use the following data for testing: var data1 = [{ id: 1, name: 'James' }, { id: 4, name: 'Jordan' }];
Error when running to "pp.data":

I modified the relevant code to:
var ppUpdate = pp.data(dataset, d => {
if(d){
return d.id
}
});
There will be no errors. But "ppUpdate.exit();" doesn't return the record I want to delete, instead it returns both records in the html. Further tracing the code execution process, in the "bindKey" function in d3.js, the correct "keyValue" cannot be obtained.

Please, how can I complete my function? thanks.