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); 

http://jsfiddle.net/2vwla/

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

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -