Jump to content


Working on a JS dropdown

Recommended Posts

Hey guys, not relay on topic. But I remember you being helpful over here a wile back. 


Working on a Js drop-down and almost have it working perfect but js is doing my head in basically. When you click on a menu item it opens and once you click off it. it closes. 


Only problem I have is if you click from one menu item to the next the first one stays open. Seems like I need to use a loop or if statement?


Have attached a codepen if you guys could do a fork that would be epic!



See the Pen yrGWEd by gsxr1000 (@gsxr1000) on CodePen

Link to comment
Share on other sites

This has more problems than before :)


Once you click on the menu item the only way to get it off is clicking on anther menu item, if you click on the menu item again it still stays active and also if you click off the menu it still stays open.   


On the original the only problem is that multiple menu drop downs can be opened.

Link to comment
Share on other sites

Hi @single0speed


Here's an alternative with mouseenter / -leave.
You can also construct a condition.


See the Pen NmoXGN by mikeK (@mikeK) on CodePen


Kind regards




  • Like 2
Link to comment
Share on other sites

I'd recommend forking one of the demos @mikel was nice enough to make for you and see if you can modify it to meet your needs. If you get stuck on any GSAP related parts of the project, we're happy to help.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.