How do I make the navigation menu hoverable as well as clickable?

How do I make the navigation menu hoverable as well as clickable?

LDLC_Shop
Tourist
14 0 8

How do I make the navigation menu hoverable as well as clickable? Clickable in a way so it directs me to the actual shop page (final page) when I click it, and the hover is just to open the navigation menu.

 

I went thru a lot of pages and I haven't found a solution so far.

 

 

Replies 3 (3)
LDLC_Shop
Tourist
14 0 8

longdistanceloveclub.com

edimar123

 

Here it is, I forgot to attach it on the first post!

PageFly-Richard
Shopify Partner
5011 1120 1805

Hi @LDLC_Shop 

 

This is Richard from PageFly - Shopify Page Builder App

 

Please add this code to your theme.liquid above the </head> to get this solved

Step 1: Online Stores > Themes > More Actions > Edit code

Step 2: click on theme.liquid and paste the code above the </head>

<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 can help you solve the issue 

 

Best regards,

Richard | PageFly

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 


All features are available from Free plan. Live Chat Support is available 24/7.

Dan-From-Ryviu
Shopify Partner
11985 2343 2521

Hi @LDLC_Shop 

You can try to add this script to theme.liquid file, before </body> tag and check again

<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.
- 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.
- Enjoy 1 month of Shopify for $1. Sign up now.