0

How do I make the submenu close when I tap it again?

https://code.sololearn.com/WGEGw8bN2MaP/?ref=app

9th Jun 2021, 4:49 PM
Abdul-Quadri
9 Respostas
+ 2
https://code.sololearn.com/Ww1oKc5GZ3lx/?ref=app
9th Jun 2021, 5:17 PM
visph
visph - avatar
+ 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
9th Jun 2021, 6:40 PM
Abdul-Quadri
0
Abdul-Quadri Do this inside function a if(div.style.display == "block") { div.style.display = "none"; } else { div.style.display = "block"; }
9th Jun 2021, 4:59 PM
AÍąJ
AÍąJ - avatar
0
🅰đŸ…č 🅐🅝🅐🅝🅣 But that will only make the display none.
9th Jun 2021, 5:04 PM
Abdul-Quadri
0
Abdul-Quadri Yes. What you want?
9th Jun 2021, 5:09 PM
AÍąJ
AÍąJ - avatar
0
visph You used tenary operator? Pls explain it to me
9th Jun 2021, 6:42 PM
Abdul-Quadri
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 ;)
9th Jun 2021, 6:47 PM
visph
visph - avatar
0
Abdul-Quadri See here. I had given you solution as you wanted. https://code.sololearn.com/WEdXxIETeSyM/?ref=app
9th Jun 2021, 6:55 PM
AÍąJ
AÍąJ - avatar
9th Jun 2021, 7:01 PM
visph
visph - avatar