JSFiddle - React, Tailwind, and code Playground
HTML
<div>Oh my god karen, you can't just ask someone why they're white.</div>
<button>^Remove</button>
JavaScript
div = document.querySelector("div");
callback = function(records){
console.log(records);
}
config = {
childList:true,
subtree:true
}
observer = new MutationObserver(callback);
observer.observe(div,config);
button = document.querySelector("button");
button.addEventListener("click",function(){
div.parentNode.removeChild(div);
});