最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - DOMsubtreemodified equivalent in IE - Stack Overflow

programmeradmin3浏览0评论

Does anyone know the equivalent of this event in 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.

Need an equivalent logic for IE8 and IE7

Does anyone know the equivalent of this event in 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.

Need an equivalent logic for IE8 and IE7

Share Improve this question asked Nov 8, 2013 at 22:19 AniAni 4,5234 gold badges28 silver badges32 bronze badges 5
  • 1 A short answer: an equivalent event doesn't exist in IE<9. However, changes to some elements/properties fire onpropertychange event. – Teemu Commented Nov 8, 2013 at 22:24
  • you can always ping and trigger a custom event upon a change detection... getElemementsByTagName("*") will change it's .length property when elements are added or removed. – dandavis Commented Nov 8, 2013 at 22:28
  • I'd suggest writing your code in such a way that you don't depend on these kinds of events. – Kevin B Commented Nov 8, 2013 at 22:28
  • @dandavis That's what my 2nd option was. – Ani Commented Nov 8, 2013 at 22:59
  • @KevinB : I am implementing other option now, which won't need this event :( – Ani Commented Nov 8, 2013 at 23:00
Add a ment  | 

1 Answer 1

Reset to default 12

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

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

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

This can be further bined into a single event listener

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

评论列表(0)

  1. 暂无评论