Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mutation observer

  var composeObserver = new MutationObserver(function(mutations){ 
    mutations.forEach(function(mutation){
      console.log("MUTATE:", mutation)
    });
});


  function addObserverIfDesiredNodeAvailable() {
    console.log('calling')
    var composeBox = document.querySelector(".title");
    console.log("compose box: ", composeBox);
    if(!composeBox) {
        //The node we need does not exist yet.
        //Wait 500ms and try again
        window.setTimeout(addObserverIfDesiredNodeAvailable,500);
        return;
    }
    var config = {childList: true};
    composeObserver.observe(composeBox,config);
}
addObserverIfDesiredNodeAvailable();
Source by jsfiddle.net #
 
PREVIOUS NEXT
Tagged: #mutation #observer
ADD COMMENT
Topic
Name
3+7 =