File size: 589 Bytes
4d6f2bc
 
 
e667f80
459aacb
4d6f2bc
459aacb
e667f80
459aacb
 
e667f80
 
459aacb
e667f80
459aacb
4d6f2bc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
() =>{
  const menu = document.querySelector("#menu");
  const menuButton = menu.querySelector("button");
  const menuSpan = menuButton.querySelector("span:first-child");
  const content = document.querySelector("#content");

  const updateMenu = () => {
    const isOpen = menuButton.classList.contains("open");
    menuSpan.textContent = isOpen ? "Hide menu" : "Show menu";
    content.style.display = isOpen ? "none" : "flex";
  };

  const observer = new MutationObserver(updateMenu);
  observer.observe(menuButton, { attributes: true, attributeFilter: ["class"] });
  updateMenu();
}