0

How do i make a button that toggles functions?

Im trying to make a website that uses a side navigation panel however the way i have it set up now requires you to use two seperate buttons to open/close the nav panel. I was wondering if there was a way to open and close the navigation panel using only 1 button

27th Jan 2019, 11:20 AM
Lochy M
Lochy M - avatar
10 odpowiedzi
0
This is what I made of it (I used some try-catch blocks at other parts because those errors where annoying af) https://code.sololearn.com/WGr977gqLD7C/?ref=app
27th Jan 2019, 12:21 PM
Roel
Roel - avatar
+ 1
Toggle functions work like this let show = true; function Toggle(){ if(show){ x.style.display = "block"; show = false; } else { x.style.display = "none"; show = true; } } Or for short let show = true; function Toggle(){ x.style.display = (show)? 'block' : 'none'; show = !show; }
27th Jan 2019, 11:36 AM
Roel
Roel - avatar
0
Can you show us the code?
27th Jan 2019, 11:26 AM
Alandec
0
I would but im on my phone rn and i dont have access to my laptop till tomorrow
27th Jan 2019, 11:27 AM
Lochy M
Lochy M - avatar
0
Actually its on my one drive
27th Jan 2019, 11:28 AM
Lochy M
Lochy M - avatar
0
Here is the website
27th Jan 2019, 11:37 AM
Lochy M
Lochy M - avatar
0
Ok I'll take a look at it and change some things
27th Jan 2019, 11:42 AM
Roel
Roel - avatar
0
Thanks! Thank you four you help!
27th Jan 2019, 11:43 AM
Lochy M
Lochy M - avatar
0
Thanks!
27th Jan 2019, 12:27 PM
Lochy M
Lochy M - avatar