-
How can I use Javascript to check if a dropdown's content is currently visible? An example scenario is that I have hooks in react-based dropdown content that I want to run only when the dropdown is open. |
Beta Was this translation helpful? Give feedback.
Answered by
saadeghi
Dec 25, 2023
Replies: 1 comment 1 reply
-
Method 1 dropdown works with HTML Method 2 dropdown works with CSS focus so you can use Let me know if you have a question. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
saadeghi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Method 1 dropdown works with HTML
<details>
tag so you can use theontoggle
event to check if it's open or not:https://www.cssportal.com/html-event-attributes/ontoggle.php
Method 2 dropdown works with CSS focus so you can use
onfocus
event:https://www.cssportal.com/html-event-attributes/onfocus.php
Let me know if you have a question.