JSFiddle - React, Tailwind, and code Playground
by KCarnaille
HTML
<div id="parent" class="test">
<p>toto</p>
</div>
<button id="removeToto">
Supprimer toto
</button>
JavaScript
var x = new MutationObserver(function (e) {
if (e[0].removedNodes) alert('toto supprimé du DOM');
});
x.observe(document.getElementById('parent'), { childList: true });
document.getElementById('removeToto').addEventListener('click', () => {
document.querySelector('p').remove();
});