How to identify when the DOM has been changed?

后端 未结 3 1311
北恋
北恋 2020-12-10 06:16

Is there a simple way to know when the DOM has been changed ?

Is there any built-in JavaScript/jQuery event/function for this ?

3条回答
  •  醉话见心
    2020-12-10 06:49

    You can attach to many DOM events depending on the type of change you wish to listen for. Here's a page with all the DOM change events:

    https://developer.mozilla.org/en/DOM_Events

    The generic, catch-all DOM change event is DOMSubtreeModified. For example:

    document.getElementById('abc').addEventListener('DOMSubtreeModified', f, false);
    

提交回复
热议问题