Looking for some help with editing my Shopify theme. I want to change the mega-menu functionality from hover to click. I've been teaching myself HTML, CSS, and delving into javascript/JQuery recently. It's all still new to me, but I'm eager to learn. Hopefully, this will be an easy fix! 🤞
I managed to partially achieve what I wanted by modifying the javascript code to use 'click' instead of 'mouseenter'. This allowed me to open the menu on click, but I struggled to close it in the same way. I have a feeling the .toggle() method might come in handy here, but I'm not sure where to begin. Any guidance would be greatly appreciated!
Here is a snippet of the HTML:
<div id="main-nav">
<div class="navigation navigation--main" role="navigation" aria-label="Primary navigation">
<div class="navigation__tier-1-container">
<ul class="navigation__tier-1">
<li class="navigation__item navigation__item--with-children">
<a href="#" class="navigation__link" aria-haspopup="true" aria-expanded="false" aria-controls="NavigationTier2-1">Browse</a>
<a class="navigation__children-toggle" href="#"></a>
<div id="NavigationTier2-1" class="navigation__tier-2-container navigation__child-tier">
<ul class="navigation__tier-2 navigation__columns navigation__columns--count-2">
<li class="navigation__item navigation__column">
<a href="/collections/new-arrivals" class="navigation__link">New Arrivals</a>
CSS style rules applied:
.navigation {
/* Styles go here */
}
/* Additional CSS styles */
.navigation ul,
.navigation li {
/* More specific styles */
}
And here is a portion of the Javascript used:
// JavaScript logic here
theme.Navigation = {
// Functions defined here
};
If you could offer any assistance, it would be greatly appreciated!