Simply use something such as:
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(function(mutations, observer) {
// fired when a mutation occurs
console.log(mutations, observer);
// Use of the information here.
});
observer.observe(document, {
subtree: true,
attributes: true
//...
});
In the call to MutationObserver
you can listen to the events and get the list of elements changed in variable mutations.
In the first argument to observer.observe
you can set the elements to listen. In the second argument to the same method you can set what you want to listen.
This code works with Chrome, Firefox and Safari. With the others browsers you can use events, such as 'DOMAttrModified'
and 'propertychange'
, if you want to just see attributes modified, in example.
Good luck.