You can use MutationObserver . To track any kind of node removed from your contenteditable element, take a look at the following example
<div id="myTextArea" contenteditable="true"> <input value="input" /> <span contenteditable="false">span</span> </div>
var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { //console.log($(mutation.removedNodes)); // <<-- includes text nodes as well $(mutation.removedNodes).each(function(value, index) { if(this.nodeType === 1) { console.log(this) // your removed html node } }); }); }); var config = { attributes: true, childList: true, characterData: true }; observer.observe($('#myTextArea')[0], config);
source share