sander-m of bGenius Design Team
4/25/2017 - 7:20 AM

Observer: live html elements updaten

Observer: live html elements updaten

      var target = $shoppingBag[0];
      // create an observer instance
      var observer = new MutationObserver(function(mutations) {
                mutations.forEach(function(mutation) {
                  // only watch and act on the newly added node (and not the removal)
                  if (mutation.addedNodes.length > 0) {
                    changeIcon(parseInt($('.aantal').text()));
                  }
                });    
              });
      // configuration of the observer:
      var config = { attributes: true, childList: true, characterData: true };
      // pass in the target node, as well as the observer options
      observer.observe(target, config);
	}