Skip to content
Advertisement

I want to fix clicking menu button problems

To hide the menu when I click on windows or scroll, I tried like this.

JavaScript

My html is like this.

JavaScript

And css is like this.

JavaScript

If you try this code, you can find when you click window once, then the button doesn’t work. When I click windows once, dropdown showed when I click the button twice. I want to solve this. I think you know more than me, so I want someone to solve this.

Advertisement

Answer

you can add event.stopPropagation to the menu button click.

JavaScript

that way when you click the button you won’t also click the window below.

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