Shopify themes, liquid, logos, and UX
Hi Shopify experts,
I need help with my mobile hamburger menu as it doesn't work when I tap on it using mobile devices. It works when I use "Inspect" on desktop but doesn't work on mobile devices.
My website is: https://ferussports.com/
Please kindly advise how do I fix this issue?
Solved! Go to the solution
This is an accepted solution.
Hi Terence,
Thanks for helping me out on this. I tried the suggested solution but it didn't work.
Mobile menu still isn't working on mobile devices.
This is an accepted solution.
Perhaps you may be doing something wrong. Can you send a screenshot of exactly where you added the code? It should be between the <head> tags. Also, when you add it here, try clearing the cache and testing in a private window. Alternatively, you can try clearing the full browser history.
Could you try the following one by one using the same methods above to see if they will work?
<script>
if (/Mobi|Android/i.test(navigator.userAgent)) {
document.querySelector('.mobile-nav-bar').addEventListener('click', function() {
var sidebar = document.querySelector('#sidebar-mobile-nav');
sidebar.classList.toggle('show');
});
}
</script>
<script>
if (window.innerWidth <= 768) {
setTimeout(function() {
document.querySelector('.mobile-nav-bar').addEventListener('click', function() {
var sidebar = document.querySelector('#sidebar-mobile-nav');
sidebar.classList.toggle('show');
});
}, 300);
}
</script>
This is an accepted solution.
Hi Terence,
I have been pasting them in theme.liquid under Layout and within <head></head>.
I have cleared my cache and browser history on my phone but all the codes provided haven't been successful.
Have I pasted it in the wrong place?
Hello!
It seems like you might have made some changes to certain codes in the theme without knowing, or perhaps installing an app caused this issue. Anyway, if you install the following code, the problem should be resolved. At least it works for me. If you can't do it, let me know, and we'll find other ways to solve the issue. Also, you can check how to install the codes from the video below.
https://www.convertout.com/blog/how-to-add-javascript-to-an-individual-shopify-page-step-by-step
<script>
document.querySelector('.mobile-nav-bar').addEventListener('click', function() {
var sidebar = document.querySelector('#sidebar-mobile-nav');
sidebar.classList.toggle('show');
});
</script>
Terence...
This is an accepted solution.
Hi Terence,
Thanks for helping me out on this. I tried the suggested solution but it didn't work.
Mobile menu still isn't working on mobile devices.
This is an accepted solution.
Perhaps you may be doing something wrong. Can you send a screenshot of exactly where you added the code? It should be between the <head> tags. Also, when you add it here, try clearing the cache and testing in a private window. Alternatively, you can try clearing the full browser history.
Could you try the following one by one using the same methods above to see if they will work?
<script>
if (/Mobi|Android/i.test(navigator.userAgent)) {
document.querySelector('.mobile-nav-bar').addEventListener('click', function() {
var sidebar = document.querySelector('#sidebar-mobile-nav');
sidebar.classList.toggle('show');
});
}
</script>
<script>
if (window.innerWidth <= 768) {
setTimeout(function() {
document.querySelector('.mobile-nav-bar').addEventListener('click', function() {
var sidebar = document.querySelector('#sidebar-mobile-nav');
sidebar.classList.toggle('show');
});
}, 300);
}
</script>
This is an accepted solution.
Hi Terence,
I have been pasting them in theme.liquid under Layout and within <head></head>.
I have cleared my cache and browser history on my phone but all the codes provided haven't been successful.
Have I pasted it in the wrong place?
Hello again! Could you please write the code right above the </head> section? Also, could you send me a screenshot of the exact place where you pasted the full code? It seems to be resolved now, right?
Hi Terence,
I pasted the codes you shared with me individually right above the </head> section but none of them worked. Did I paste it in the right section/code?
Please see below a screenshot.
Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024