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
6 ответов
+ 3
https://code.sololearn.com/WS93gQC7p0PA/#html
+ 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
+ 2
Use menuOpen as global variable
line 43 is perfect for var menuOpen = false ;
+ 2
https://code.sololearn.com/WIbVocEVc2l6/?ref=app
u didn't really do like we told u😉
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 😔