Determine whether an HTML combo box is expanded or collapsed
I have the need of determining, via Javascript, if a drop box is expanded or collapsed.
When the user clicks on the drop box, it gets focus and expands, while after selecting an option is keeps focused but looks collapsed. I don't care about the focus, I need to test for collapsing.
How can I do that?
Th开发者_如何学运维ank you
[Edit] I'm using a plain old <select>
tag
How about checking the visible children of dropbox div ?
In Firefox (with the Firebug extension installed), see what CSS classes are applied to the combobox when it is expanded and collapsed. If there's a class unique to when the box is in its collapsed state, you can use Javascript to check when the combobox has that class.
Or, if you're controlling the combobox yourself, you can add or remove a CSS class to let you know what the state is of the box.
精彩评论