For example, I have a p element, which contains some text, and then I have a button, click the button to replace the content in the p element, so what kind of events can be bound to element p to notify me that it has been modified? is there any implementation method? For example, I have a p element, which contains some text, and then I have a button, click the button to replace the content in the p element, so what kind of events can be bound to element p to notify me that it has been modified? is there any implementation method?
Reply content:
For example, I have a p element, which contains some text, and then I have a button, click the button to replace the content in the p element, so what kind of events can be bound to element p to notify me that it has been modified? is there any implementation method?
Http://stackoverflow.com/questions/9470931/is-there-any-on-dom-change-event
The latest MutationObserver should be able to meet your needs, see https://developer.mozilla.org/zh-CN/docs/Web/API/MutationObserver
MutationObserver provides developers with the ability to make appropriate responses when DOM trees change within a certain range.
Covers sub-node changes and attribute changes.
If event listeners, such as DOMNodeInserted and DOMNodeRemoved, are used, they are more intuitive. However, MutationObserver is designed to replace Mutation events -- DOMNodeInserted.
This design is somewhat like Promise, with no event listener shadow.
Thank you for your invitation. Click the event to sendajax
Request to send the modified operation to another user.
The p element does not exist.change
Event, so you have to perform logic processing when you click the button. clicking this button will definitely modify the content of the p element. The bad thing is that if you modify p in multiple places, in this case, we need to repeat the same logic processing. However, if you use a framework, such as watcher provided by angular and vue
DOMSubtreeModified
This event is rarely used ....