Possible Duplicate:
Detect changes in the DOM
I need to setup an event handler, which should fire whenever something is appended/changed/removed on the DOM. This answer does not work in my case. The DOM can be modified by third party developers, and on each DOM change, we need to run our script to validate the code. The event should not fire on input/textarea/select change.
We do not target all browsers. As long as it works on Webkit (Chrome, Safari), it's good enough.
Any ideas?
When you update the DOM, the reflow and repaint happen. Every time the DOM changes, the browser needs to recalculate the CSS, do a layout and repaint the web page. React doesn't really do anything new. It's just a strategic move.
We insert a new p element after 1 second 5 times. We pass in a callback into the MutationObserver constructor that runs when the DOM changes. Then we call observe on the element that we want to observe changes for. subtree set to true means that we watch for child element changes.
Angular does not provide something built-in for that purpose. You can use MutationObserver to detect DOM changes.
Events are a part of the Document Object Model (DOM) Level 3 and every HTML element contains a set of events, which can trigger JavaScript code.
DOM mutation events (I believe not supported in all browsers) .. see http://en.wikipedia.org/wiki/DOM_events#Common.2FW3C_events
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With