Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <body> <div contentEditable id="elemId">Click and <b>edit</b>...</div> <script> let observer = new MutationObserver(mutationRecords => { alert(mutationRecords); // alert(the changes) }); // observe everything except attributes observer.observe(elemId, { childList: true, // observe direct children subtree: true, // lower descendants too characterDataOldValue: true, // pass old data to callback }); </script> </body> </html>