javascript DOM 子树修改等效于 IE

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19869547/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 17:05:54  来源:igfitidea点击:

DOMsubtreemodified equivalent in IE

javascriptjqueryinternet-explorerdom

提问by Ani

Does anyone know the equivalent of this event in IE ?

有谁知道 IE 中这个事件的等价物?

Or may be a way around for this logic:

或者可能是这种逻辑的一种解决方法:

  document.addEventListener("DOMSubtreeModified", function (e) {
            if ($(e.target).hasClass("myclass")) {
                var getId= e.target.id;
            }
        }, false)

This works fine in FF, Chrome, Safari, IE 9 or higher.

这适用于 FF、Chrome、Safari、IE 9 或更高版本。

Need an equivalent logic for IE8 and IE7

需要 IE8 和 IE7 的等效逻辑

回答by JJones

I had a similar problem (though I was using jQuery). I solved it by using the following

我有一个类似的问题(虽然我使用的是 jQuery)。我使用以下方法解决了它

//chrome / ff
$(".myClass").on("DOMSubtreeModified", function() {
//do stuff
});     

//i.e.
$(".myClass").on("propertychange", function() {
//do same stuff 
});     

This can be further combined into a single event listener

这可以进一步组合成单个事件侦听器

$('.myClass').on('DOMSubtreeModified propertychange', function() {
    // do stuff
});