[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/wsr/ - Worksafe Requests

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


Janitor applications are now being accepted. Click here to apply.


[Advertise on 4chan]


I'm trying to make a simple "hamburger menu" on my website. When you click the burger icon, a menu pops up, and it goes away when you either click the burger or anywhere else outside the menu.

It works except for one part. Once the menu is open, I can't close it by pressing the same burger button again. There's some logical conflict here that I'm too dumb to detect.
The part that doesn't work is this:
>if(menu.style.display == "block") {
>menu.style.display = "none";
>}

Menu means the actual pop-up menu, menubtn is the burgerbutton that opens up the menu.

Another issue: this won't work on my cellphone, only computer. I'm not a JS guy
>>
baka! line 79 should be else if (or a switch/case statement). when the menu is open and you click the button, line 76 activates and closes the menu, then line 79 activates and, because the menu is closed, re-opens the menu
this is what debuggers/steppers are for, anon!
>>
>>1540995
Thank you anoned.
What's a debugger/stepper? I'm using notepad.exe.

Also, any idea why the code doesnt work on mobile?
>>
>>1541003
>What's a debugger/stepper?

A tool you use for debugging by stepping through your code.
Stepping means exactly that, going step by step. Instead if it zipping throug in a microsecond you do one action, stop, next step, where is the priogram now, what values does it get, next step, where are we now, where did it jump, etc...
>>
>>1541003
What's a debugger/stepper?

wow man go learn to use a debugger. it will save you soooo many headaches.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.