How to Make Mega-Menu Open on Hover over Menu Item in Trade Theme

How to Make Mega-Menu Open on Hover over Menu Item in Trade Theme

jordanbford1
Explorer
52 0 13

Hi!

 

How do I make my mega-menu appear when hovering over my main menu item with my mouse? Right now I am currently having to click to make the mega-menu to appear and I hate it. 

 

Screenshot 2024-12-30 at 01.44.29.png

 

Here is my website.

Reply 1 (1)

Dan-From-Ryviu
Shopify Partner
11522 2254 2435

Hi @jordanbford1 

You can try to add this code to theme.liquid file before </body> tag and check if it work

<script>
  document.addEventListener("DOMContentLoaded", function() {
    const inlineMenu = document.querySelector(".header__inline-menu");
    const detailsItems = inlineMenu.querySelectorAll("details");
  
    detailsItems.forEach(item => {
      const ulElement = item.querySelector("ul");
  
      item.addEventListener("mouseover", () => {
        item.setAttribute("open", true);
  
        ulElement.addEventListener("mouseleave", () => {
          item.removeAttribute("open");
        });
  
        item.addEventListener("mouseleave", () => {
          item.removeAttribute("open");
        });
      });
    });
    });
</script>  

- Helpful? Like & Accept solution! - Support me? Buy me a coffee
- Ryviu - Product Reviews & QA app: Collect customer reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Dhgate and CSV.
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...
Sign up now.