Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
How do i make it so the menu drops down when I hover the mouse over it instead of only when I click it?
Solved! Go to the solution
This is an accepted solution.
Glad to help! Could you please mark it as an accepted solution?
hello @Caligirl917
Please provide website url and if your store is password protected then also provide password So I will check and provide a solution here.
Please share your store URL!
Thanks!
Hi Sara, I just posted a video tutorial on my Youtube channel that may be what you are looking for.
Steps
1. Open your site's code editor
2. Open your site's header.liquid file (should be located in the sections folder
3. On around line 500 you will see a liquid tag referring to sticky headers, after this line copy the following code (it's a simple script that adds hover eventListeners to all menu items that create dropdowns)
<script> let items = document.querySelector(".header__inline-menu").querySelectorAll("details"); console.log(items) items.forEach(item => { item.addEventListener("mouseover", () => { item.setAttribute("open", true); item.querySelector("ul").addEventListener("mouseleave", () => { item.removeAttribute("open"); }); item.addEventListener("mouseleave", () => { item.removeAttribute("open"); }); }); }); </script>
Hope this helps, let me know if you have any issues!
This is an accepted solution.
Glad to help! Could you please mark it as an accepted solution?
Hello,
Is there a way I can have the submenus and their options displayed all at once (preferably in separate columns) while hovering over the main parent menu? So you wouldn't have to hover over the submenus as well to see their options?
Thanks!
Question about editing the source code, when Shopify does updates, does it override the code that we insert and we have to do it all over again later, or does our code remain intact and unchanged? Thanks.
Just dropping by for the solution thought I'd answer your question.
No, Shopify does not change amended code upon update to my knowledge. This would make a lot of businesses extremely unhappy, as most professional Shopify stores have custom code to some capacity. Hope this helps.
This solution not work with Dawn 2.0
Try this one. No javascript being use. Just HTML and css. Check the video for more info
Thank you so much. I've been trying to find this for my Sense theme fore the longest while now. You are a lifesaver.
Hi @wmisback ,
first of all thank you for the code as well as for your videos on YouTube. I tried it out and it worked perfectly for me, the only thing is, that I have two submenu points under my menu. Now with the help of your code I can hover over the menu items and also select my submenu pages but when I move my mouse away from the first item, the entire menu closes and I can't select my 2nd sub-item at all or move my mouse to the 2nd sub-item. Do you also have this problem or is there any known solution for something like this?
I hope you can help me.
Thank you in advance
Maollin
Not Working on Dawn 2.0
This worked beautifully!
Thank you.
In the new 5.0 this opens the megamenu, but when you try to move the mouse down to the menu it closes. Any idea?
User | RANK |
---|---|
210 | |
110 | |
88 | |
56 | |
45 |