Friday, 15 March 2013

javascript - With mutation observer, Is there a way for me to get the id or class of an element or child that has changed? -


I would like to know what changes have been made in the DOM and I want to know very specific information. I want to know which element has changed from the id, or if there is no ID or class, then I want to know where I can get this element. I am trying to complete it with a mutated supervisor. Here and here's the current code:

  & lt; Div id = "divTarget" & gt; & Lt; P & gt; Hello World & lt; / P & gt; & Lt; / Div & gt; & Lt; Button ID = "btnUpdate" & gt; Update target & lt; / Button & gt; Var fnCallback = function (mutations) {mutation.forEach (warning (mutation type, "Added:" + mutation.addedNodes.length + "nodes"); Warning (mutation type, "Deleted: "+ Mutation.removedNodes.length +" nodes ");}); }; Var observer = new MutationObserver (fnCallback), elTarget = document.query selector ("#divitagrams"), objConfig = {childList: true, subtree: true, attributes: true, characterization: true, attributeFilter: ['style', 'id '], AttributeOldValue: true}; Supervisor Promotions (Altags, Ozongfig); // Here only the test code var btnUpdate = document.querySelector ("# btnUpdate"), fnHandler = function () {elTarget.innerHTML = "& lt; h2> New Content " ; }; BtnUpdate.addEventListener ("click", fnHandler, false);  


No comments:

Post a Comment