Для IE 11+ и ост. браузеров:
var target = document.querySelector('#some-id');
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
// ...
});
});
var config = { attributes: true };
observer.observe(target, config);
Для IE 9+, FF, Opera
var target = document.querySelector('#some-id');
target.addEventListener("DOMAttrModified", function (ev) {
// ...
}, false);
Подробнее -
https://developer.mozilla.org/en-US/...tationObserver,
https://developer.mozilla.org/en-US/...utation_events