我可以用 JavaScript 打开一个选择框吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6992639/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 00:10:34  来源:igfitidea点击:

Can I open a selectbox with JavaScript?

javascriptjqueryjavascript-events

提问by timopeschka

Possible Duplicate:
Show select dropdown in jQuery?

可能的重复:
在 jQuery 中显示选择下拉列表?

Is it possible to open a selectbox with JavaScript? Or with jQuery?

是否可以使用 JavaScript 打开选择框?还是用jQuery?

回答by mtahmed

In short: no, it's not possible. Long answer, see How do you open a select box with JavaScript?.

简而言之:不,这是不可能的。长答案,请参阅如何使用 JavaScript 打开选择框?.

回答by JMax

If you want to "open" a selectbox, this is impossible - see Stack Overflow question Click trigger on select box doesn't work in jQueryfor more information.

如果您想“打开”一个选择框,这是不可能的 - 请参阅堆栈溢出问题单击选择框上的触发器在 jQuery 中不起作用以获取更多信息。

If you want to select a value, you should use .val().

如果要选择一个值,则应使用.val().

回答by Calum

Duplicate: Show select dropdown in jQuery?

重复:在 jQuery 中显示选择下拉列表?

Can't be done, you can use .trigger('focus')but it will not open the drop down.

不能做,可以用,.trigger('focus')但是打不开下拉。