问题描述
可能的重复:
检测 DOM 中的变化
我需要设置一个事件处理程序,它应该在 DOM 上附加/更改/删除某些内容时触发.这个答案在我的情况下不起作用.DOM 可以由第三方开发人员修改,并且在每次 DOM 更改时,我们都需要运行我们的脚本来验证代码.该事件不应在 input/textarea/select 更改时触发.
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.
我们并非针对所有浏览器.只要它适用于 Webkit(Chrome、Safari),就足够了.
We do not target all browsers. As long as it works on Webkit (Chrome, Safari), it's good enough.
有什么想法吗?
推荐答案
DOM 突变事件(我相信并非所有浏览器都支持).. 参见 http://en.wikipedia.org/wiki/DOM_events#Common.2FW3C_events
DOM mutation events (I believe not supported in all browsers) .. see http://en.wikipedia.org/wiki/DOM_events#Common.2FW3C_events
这篇关于是否有任何“关于 DOM 的变化"?事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!