hover for downdrop menu theme Dawn 15.02

hi i want my header with menu to hover to submenus instead of clicking. tried several codes but nothing seems to work. thanks

I am using the dawn theme 15.02 and there is nothing in header or navigation to change it to hover

Hi it’s still not working i put it where you said to put it

Hi @Noranono

You can add this code to theme.liquid file, before in Online Store > Themes > Edit code


Hi @Noranono

Put the following code into the header.liquid file

document.querySelectorAll('details').forEach(function (details) {
  details.addEventListener('mouseenter', function () {
    details.setAttribute('open', 'true');
    details.setAttribute('aria-expanded', 'true');
    
    document.querySelectorAll('details').forEach(function (otherDetails) {
      if (otherDetails !== details) {
        otherDetails.removeAttribute('open');
        otherDetails.setAttribute('aria-expanded', 'false');
      }
    });
  });

  details.addEventListener('mouseleave', function () {
    if (!details.contains(event.relatedTarget)) { 
      details.removeAttribute('open');
      details.setAttribute('aria-expanded', 'false');
    }
  });
});