jquery - Track display changes on HTML element with Javascript -
suppose have given html element, such as:
<div id="foo">...</div>
inside element, lots of things can happen change display configurations of element, height or fixed position.
is there anyway can track changes related display of element? there general event gets fired when element changes display variable?
simply use such as:
mutationobserver = window.mutationobserver || window.webkitmutationobserver; var observer = new mutationobserver(function(mutations, observer) { // fired when mutation occurs console.log(mutations, observer); // use of information here. }); observer.observe(document, { subtree: true, attributes: true //... });
in call mutationobserver
can listen events , list of elements changed in variable mutations.
in first argument observer.observe
can set elements listen. in second argument same method can set want listen.
this code works chrome, firefox , safari. others browsers can use events, such 'domattrmodified'
, 'propertychange'
, if want see attributes modified, in example.
good luck.
Comments
Post a Comment