Re: Trouble with Hover Menu, Want Hover on top level and click on sub level

Trouble with Hover Menu, Want Hover on top level and click on sub level

1 0 0

Hey guys,


So, I've got a hover menu for my store. 


Here is the code:


let items = document.querySelector(".header__inline-menu").querySelectorAll("details");
items.forEach(item => {
item.addEventListener("mouseover", () => {
item.setAttribute("open", true);
item.querySelector("ul").addEventListener("mouseleave", () => {
item.addEventListener("mouseleave", () => {



The problem I'm having is that when hovering over submenu items, it opens them straight away.


I would like only the top-level menu to be hover, but for sections underneath to be click to expand.


So, for example, you hover on 'Women's' and the menu appears.


But then when hovering on 'Tops' under 'Women's', I don't want anything to happen, and right now it's automatically expanding on hover, I want customers to have to click.


Also, I don't like that you can have several of them open at the same time, so I can open up tops, bottoms, each sub menu at the same time, but I want it so that if you open tops, it closes bottoms and just gives you a clear view of that one sub category.


Is there a way so that when you open one submenu it closes all the others?


If I can implement these two things the menu will be perfect.


Let me know of any solutions, thanks everyone.




Reply 1 (1)

Shopify Partner
1558 355 381

Hi @hybrydstore,


Can you provide link to the store?

Buy me a Coffee

Enjoy Shopify for $1. Sign up now

For quick response - Message Me

Ping me at: