8

I'm using "MutationObserver" to detect if content changes in a div.

It works fine in Firefox, Safari, Chrome, IE11, etc, but I cannot get it to work in IE10.

A did a search and it looks like IE10 doesn't support "MutationObserver" but you can use the following "PolyFill" to make it work: https://github.com/googlearchive/MutationObservers/blob/master/MutationObserver.js

I tried this but it's still not working.

Am I loading the MutationObserver.js fix incorrectly? Or does anyone know of a better way to detect if div content changes in IE10?

JSFiddle here: https://jsfiddle.net/hvt217dm/

Code here:

"use strict";

    // Change content
    $(".button1").click(function() {
        $(".content1").html("Test 2");
    });

    // Check if content has changed
    var target = document.querySelector(".content1");
    var observer = new MutationObserver(function(mutations) {
        alert("Changed");
    });
    var config = { attributes: true, childList: true, characterData: true };
    observer.observe(target, config);
Yash
  • 1,020
  • 1
  • 15
The Bobster
  • 573
  • 4
  • 20
  • This is the most suitable working answer I found : [https://stackoverflow.com/a/3219767/20896084](https://stackoverflow.com/a/3219767/20896084) – Yash Mar 02 '23 at 18:22

0 Answers0