0

Problem with navigation menu in my simple HTML page. Need to click the hamburger icon twice to open the menu.

I stuck on a problem while designing the header for my blog.. * The action I wanted is that whenever user clicks the hamburger icon, the menu will open. * If the user clicks the hamburger icon when the menu is open, the menu will close, * When the user clicks outside the menu when the menu is open, then it will also close the menu. Everything thing upto here is working fine. But the problem is that when the user opens the menu by clicking the hamburger icon and closes the menu by clicking outside the menu area, I should press the hamburger menu twice to open the menu. Please check my code to see the problem and help me to fix it, thank you. https://code.sololearn.com/WFyHGNqw2680/?ref=app

26th Oct 2020, 3:37 AM
Bibek Oli
Bibek Oli - avatar
6 Antworten
+ 3
https://code.sololearn.com/WS93gQC7p0PA/#html
26th Oct 2020, 9:56 AM
ODLNT
ODLNT - avatar
+ 3
Your problem is at line 109 remove window. leaving just menuOpen = false; "let does not create properties of the window object" https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let
26th Oct 2020, 6:23 AM
ODLNT
ODLNT - avatar
+ 2
Use menuOpen as global variable line 43 is perfect for var menuOpen = false ;
26th Oct 2020, 6:30 AM
Oma Falk
Oma Falk - avatar
+ 2
https://code.sololearn.com/WIbVocEVc2l6/?ref=app u didn't really do like we told u😉
26th Oct 2020, 7:25 AM
Oma Falk
Oma Falk - avatar
+ 1
Thank you Frogged and ODLNT for your answer. I tried both one by one and also combined, but it is not working (the problem is same)😌 Can you send me the working version of the code.
26th Oct 2020, 7:23 AM
Bibek Oli
Bibek Oli - avatar
0
Frogged doing that doesn't close the menu by pressing the X button😂, only clicking outside does. I have been trying to solve this since yesterday, if one method is working, another doesn't 😔
26th Oct 2020, 7:29 AM
Bibek Oli
Bibek Oli - avatar