Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. // Select the node that will be observed for mutations
  2. var targetNode = document.getElementById('testingMutation');
  3.  
  4. // Options for the observer (which mutations to observe)
  5. var config = { attributes: true, childList: true, characterData: true, subtree: true, attributeOldValue: true };
  6.  
  7. // Callback function to execute when mutations are observed
  8. var callback = function(mutationsList) {
  9. for(var mutation of mutationsList) {
  10. console.log(mutation)
  11. }
  12. };
  13.  
  14. // Create an observer instance linked to the callback function
  15. var observer = new MutationObserver(callback);
  16.  
  17. // Start observing the target node for configured mutations
  18. observer.observe(targetNode, config);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement