← Snippets - Script

Mutation Observation

Definition

Usage

  • This lets you make changes to code injected from Banno tags after the page loads.

Basic Setup

// select a single element (querySelectorAll will need a forEach() set up to work)
const targetElement = document.querySelector('#id or .class selector');

// if element exists, observe
if (targetElement != null){
  const targetElementObserver = new MutationObserver(function(){
    // do stuff to things
  });

  observer.observe(targetElement, {subtree: true, childList: true});
}