Skip to content
Advertisement

Collapsible direct drop down menu with JS

I’m trying to create a drop down menu that exposes the content when it’s hovered over. I didn’t know how to do it myself so I referenced W3school’s collapsible tutorial’s code.

In the tutorial the collapsible opens when clicked on, and I was able to make it open when hovered over, but it’s automatically closes when I try and hover over the content within. I need it to stay open when I hover over the internal content. I don’t really know any js though so could someone help me?

JavaScript

Advertisement

Answer

You need to handle the mouseenter and mouseleave event, but please do a container for both of the elements so that you can refer those events to it (as it includes both elements)

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement