0
How do I make the submenu close when I tap it again?
9 Respostas
+ 2
https://code.sololearn.com/Ww1oKc5GZ3lx/?ref=app
+ 1
đ
°đ
č đ
đ
đ
đ
đ
Ł I'm sorry, I meant to say, "how to make the submenu close when I tap it again".
Like when I tap it once, it would open but if I tap it again it should close.
I've edited the question. Thanks though
0
Abdul-Quadri
Do this inside function a
if(div.style.display == "block") {
div.style.display = "none";
} else {
div.style.display = "block";
}
0
đ
°đ
č đ
đ
đ
đ
đ
Ł But that will only make the display none.
0
Abdul-Quadri
Yes. What you want?
0
visph You used tenary operator?
Pls explain it to me
0
the menu open when you tap once the image, then if you tap again the image, the menu will close...
if you want to close the menu when you tap it, then you should apply your b function on the onclick event of the div...
ternary operator return left hand side colon value if condition before question mark is true else return right hand side...
if inlined display style property is set it is evaluated as true, so we clear it, else if not, then we assign it 'block' value ;)
0
Abdul-Quadri
See here. I had given you solution as you wanted.
https://code.sololearn.com/WEdXxIETeSyM/?ref=app
0
Abdul-Quadri updated version of mine solution:
https://code.sololearn.com/WenwGaWar1Of/?ref=app