开发者

Display DropDown options on Focus [duplicate]

This question already has answers here: How can you programmatically tell an HTML SELECT to drop down (for example, due to mouseover)? (16 answers) 开发者_StackOverflow Closed 9 years ago.

I have a simple html dropdown, I wants to use jQuery if possible to display all the options if this control has the focus(as if the user click on the dropdown). I have tried jQuery trigger(), click(), to avail.

  <select id="single">
    <option>Single</option>
    <option>Single2</option>
  </select>


Since the UI element that represents the drop-down-list comes from the host browser, it's not really inside the JS sandbox - rather, we merely have a DOM object that represents the things about the element we can manipulate - option list, style, and which index is selected. The behavior of interacting inside the element - expanding/collapsing, etc happens at the browser chrome level - same as tabs, file menu, etc. - outside the JS sandbox. The standard does not call for notifying the DOM when the DDL is opened, only when it is focused.

So, short answer - no.


I would recommend using a comboBox. That should allow you to do what you want.

http://simpletutorials.com/?path=tutorials/javascript/jquery/ddcombobox

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜