OLSP
February 1, 2024, 2:27am
1
Hi, i am currently using anchor links for my header menu and it works fine on desktop. However, on mobile, clicking on any of the anchor links does not close the menu. Is there a way to close the menu after clicking on my anchor links?
I am currently on the Publisher theme.
https://38550a-2.myshopify.com/
pw: ov24
You can try to add this code to your Online store > Themes > Edit code > open theme.liquid file, add code before and check if it works
document.addEventListener('DOMContentLoaded', function () {
const newsletterLinks = document.querySelectorAll('.menu-drawer__menu-item');
newsletterLinks.forEach(function (link) {
link.addEventListener('click', function () {
document.querySelector('#Details-menu-drawer-container span').click();
});
});
});
OLSP
February 1, 2024, 3:13am
3
Hi Dan,
Appreciate you trying to help. I have inserted the code before but it still does not work. Nothing seems to have changed.
Please try to update code to this and check again
2 Likes
OLSP
February 1, 2024, 3:21am
5
Works like a charm! Thanks Dan!
Worked great in 2025 with Sense theme, thank you!!
1 Like