Skip to content
Advertisement

How to make hamburger close upon click of links

I know this has been asked before, but my setup seems different than the ones I’ve found so far.

My code is as follows (really bad at coding, by the way)

JavaScript

Not sure what to do to make the hamburger fold after clicking one of the anchor links.

Also, for some reason some iOS users state that the menu (when not in hamburger) is on the left, not centered.

Thank you!

Advertisement

Answer

You could add the same function to those navigation items.

JavaScript

Or you could add it to all those together, since you are calling the same function.

JavaScript

and remove it from your html:

JavaScript

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