How to identify when the DOM has been changed?

后端 未结 3 1310
北恋
北恋 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 07:00

    If you must detect changes you can check the DOM mutation events. The DOM events wikipedia page lists them all. However you should know that they are not supported in Internet Explorer and may fire too often in the browsers that support them. A brute force approach is to use setTimeout and check for changes by yourself.

    My experience shows though that the need for DOM change notifications can be avoided. Could you give more details about your exact requirements?

提交回复
热议问题