本文介绍了DOMNodeInserted 在 IE 中等效吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了使用计时器来计算一段时间内的元素数量并寻找变化之外,我想不出更好的方法来模拟这个事件.

Other than using a timer to count the number of elements over time and looking for changes, I can't think of a better way to simulate this event.

是否有某种专有的 IE 版本的 DOMNodeInserted?谢谢.

Is there some sort of proprietary IE version of DOMNodeInserted? Thanks.

推荐答案

不,没有.最接近的是 propertychange 事件,它响应元素的属性或 CSS 属性的更改而触发.它在响应直接更改元素的 innerHTML 属性时触发,但不会在元素的内容通过其他方式(例如,通过使用诸如 appendChild() 或通过改变子元素的 innerHTML).

No, there isn't. The nearest is the propertychange event, which fires in response to a change in an attribute or CSS property of an element. It fires in response to changing the innerHTML property of an element directly but not when the contents of the elements are altered by some other means (e.g. by using DOM methods such as appendChild() or by altering the innerHTML of a child element).

正如评论中所指出的,有一个解决方法.它基于精心设计的 hack,我建议尽可能使用变异观察器..@naugtur 的回答已被删除,但可以在 https://github.com/naugtur/insertionQuery 找到解决方案一个>

As pointed out in the comments, there is a workaround. It's based on an elaborate hack and I'd recommend using mutation observers instead wherever possible. . @naugtur's answer has been deleted but the solution can be found at https://github.com/naugtur/insertionQuery

这篇关于DOMNodeInserted 在 IE 中等效吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 09:19