From 16632706e0a0a4be4a8a052ab03291ac8bfc5932 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 16 Apr 2023 19:33:13 +0200 Subject: [PATCH] menu: Don't scroll to top when clicking info --- resources/assets/js/forms.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/resources/assets/js/forms.js b/resources/assets/js/forms.js index 26557a13..2280e7cb 100644 --- a/resources/assets/js/forms.js +++ b/resources/assets/js/forms.js @@ -313,3 +313,15 @@ ready(() => { }); } }); + +/** + * Prevent scrolling on # links in menu + */ +ready(() => { + const elements = document.querySelectorAll('.navbar a[href="#"]'); + elements.forEach((a) => { + a.addEventListener('click', (e) => { + e.preventDefault(); + }); + }); +});