According to the documentation, use the attributeFilter array and list the HTML attributes, 'style' here:
var observer = new MutationObserver(styleChangedCallback); observer.observe(document.getElementById('childDiv'), { attributes: true, attributeFilter: ['style'], }); var oldIndex = document.getElementById('childDiv').style.zIndex; function styleChangedCallback(mutations) { var newIndex = mutations[0].target.style.zIndex; if (newIndex !== oldIndex) { console.log('new:', , 'old:', oldIndex); } }
source share