javascript - Is there a way to track all change to an HTML element? -
is there (good) way track changes html element ?
i tried use javascript jquery not work.
$('div.formsubmitbutton input[type="submit"]').change(function(event){ alert(event); }); somehow style attribute set on submit button can't find , how done.
you can track changes done dom element using mutationobservers:
// select target node var target = document.queryselector('div.formsubmitbutton input[type="submit"]'); // create observer instance var observer = new mutationobserver(function(mutations) { mutations.foreach(function(mutation) { console.log(mutation); }); }); // configuration of observer: var config = { attributes: true, childlist: true, characterdata: true } // pass in target node, observer options observer.observe(target, config); this give mutationrecord object details on changed. more info mutations at: https://hacks.mozilla.org/2012/05/dom-mutationobserver-reacting-to-dom-changes-without-killing-browser-performance/
Comments
Post a Comment