0

How can I run certain function when style attribute of certain div gets set to display: none?

fivepointseven
  • 1,041
  • 2
  • 11
  • 23
  • 1
    What about this? http://stackoverflow.com/questions/2157963/is-it-possible-to-listen-to-a-style-change-event – Nathan Jun 28 '15 at 19:59

1 Answers1

0

What about this?

var observer = new MutationObserver(function(mutations) {
    mutations.forEach(function(mutationRecord) {
        console.log('style changed!');
    });    
});

var target = document.getElementById('myId');
observer.observe(target, { attributes : true, attributeFilter : ['style'] });

Mozilla: https://developer.mozilla.org/en/docs/Web/API/MutationObserver

No jQuery is required. However, it is only supported in modern browsers (IE11+).

If you wish to use jQuery, I suppose you could modify the .css function or something.

Fore more information: Is it possible to listen to a "style change" event?

Community
  • 1
  • 1
Nathan
  • 1,321
  • 1
  • 18
  • 32