diff --git a/assets/script.js b/assets/script.js index e69de29..ef3a6c2 100644 --- a/assets/script.js +++ b/assets/script.js @@ -0,0 +1,20 @@ +document.addEventListener("DOMContentLoaded", () => { + // just open the menu + document.querySelectorAll(['[data-menu-open]']).forEach((el) => el.addEventListener('click', event => { + event.preventDefault(); + const menu = document.getElementById(el.getAttribute('data-menu-open')); + menu.style.display = 'block'; + })); + // just close the menu + document.querySelectorAll(['[data-menu-close]']).forEach((el) => el.addEventListener('click', event => { + event.preventDefault(); + const menu = document.getElementById(el.getAttribute('data-menu-close')); + menu.style.display = 'none'; + })); + // switch between open and close + document.querySelectorAll(['[data-menu-toggle]']).forEach((el) => el.addEventListener('click', event => { + event.preventDefault(); + const menu = document.getElementById(el.getAttribute('data-menu-toggle')); + menu.style.display = menu.style.display == 'block'? 'none': 'block'; + })); +});