+ 3
How can I make the drop down list disappear when I click on the button again ?
3 odpowiedzi
+ 5
This is how I usually do it:
https://code.sololearn.com/WO3PFQ61h3ia/?ref=app
+ 3
On the onclick attribute of button, just call a function like this :
<button onclick="toggle ()" > menu </button>
Now in JavaScript file, write the following code :
let visible = false;
function toggle(){
if (visible){
document.getElementById('list').style.display='none';
visible = false;
}
else{
document.getElementById('list').style.display='flex';
visible = true;
}
}
+ 1
1.way:
create js function which chenges x value from 1 to 0 and from 0 to 1 each time button clicked and set property display: none;
2.way:
use CSS hidden checkbox labeled as button.
when checkbox selected display: flex;
when unchecked
display: none.