How can I run certain function when style
attribute of certain div gets set to display: none
?
Asked
Active
Viewed 344 times
0

fivepointseven
- 1,041
- 2
- 11
- 23
-
1What 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 Answers
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?
-
I'm gonna be using Phantom.js and wanted to inject script to a page. But thanks anyway! – fivepointseven Jun 28 '15 at 20:05