开发者

Programmatically open a drop-down menu [duplicate]

This question already has answers here: 开发者_StackOverflow社区 Closed 12 years ago.

Possible Duplicate:

How can you programmatically tell an HTML SELECT to drop down (for example, due to mouseover)

Is there a way to programmatically display/open a drop down menu (<select>)?


After trying a few things, I could not get it to work. So maybe the answer might be "it is impossible". Sorry!

The only way you could probably do it is to use one of the jQuery plugins that turn a normal select element into normal elements that are styled. Then it should be trivial to set display: block on one of the elements the plugin produces.


I'll often program in a series of <select>/<option> tags, but then replace it with jQuery to become an anchor than spawns a <div> when clicked, and the <div> contains a <ul> of the options. This allows for better styling, and can be quite keyboard accessible if you choose to program that in.

I mostly do it because my designer insists upon non-native form elements.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜