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
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
+ 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;
}
0
Can you show us the code?
0
I would but im on my phone rn and i dont have access to my laptop till tomorrow
0
Actually its on my one drive
0
Here is the website
0
Ok I'll take a look at it and change some things
0
Thanks! Thank you four you help!
0
Thanks!