DOMNodeInserted等效于IE? [英] DOMNodeInserted equivalent in IE?

查看:170
本文介绍了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).

正如评论中所指出的,有一个解决方法。它是基于一个精心制作的黑客,我建议使用变异观察者,而不是尽可能。 请参阅@ naugtur的答案以了解详情。 @ 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. See @naugtur's answer for details. @naugtur's answer has been deleted but the solution can be found at https://github.com/naugtur/insertionQuery

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆