From 90a4e9e74009efa249270774fcbb1729d4f44bed Mon Sep 17 00:00:00 2001 From: stan-turing Date: Wed, 18 Dec 2024 11:46:43 +0100 Subject: [PATCH] Fixed Menu Autoclose on click of button --- index.html | 9 +-------- script.js | 12 +++++++++++- scripts.js | 0 3 files changed, 12 insertions(+), 9 deletions(-) delete mode 100644 scripts.js diff --git a/index.html b/index.html index cd27860..eb9d0aa 100644 --- a/index.html +++ b/index.html @@ -90,13 +90,6 @@ Impressum - + \ No newline at end of file diff --git a/script.js b/script.js index 8f1327f..53746fa 100644 --- a/script.js +++ b/script.js @@ -2,4 +2,14 @@ hamburger = document.querySelector(".hamburger"); hamburger.onclick = function() { navBar = document.querySelector(".nav-bar"); navBar.classList.toggle("active"); -} \ No newline at end of file +} + +const menuButtons = document.querySelectorAll(".nav-bar a"); +menuButtons.forEach(button => { + button.addEventListener("click", () => { + const navBar = document.querySelector(".nav-bar"); + navBar.classList.remove("active"); // Menü schließen + }); +}); + +document.getElementById("year").innerHTML = new Date().getFullYear(); diff --git a/scripts.js b/scripts.js deleted file mode 100644 index e69de29..0000000