使html选择选项下拉菜单默认打开 [英] Make html select option drop down menu open by default
问题描述
单击选择框后,将显示一个选项下拉列表.下拉列表保持打开状态,直到用户单击外部或在下拉列表中选择一个选项为止.
When the select box is clicked, a drop down list of options is displayed. The drop down list stays open until the user clicks outside or selects one of the options in the drop down list.
有没有一种简单的方法可以使用户进入页面时显示下拉列表?喜欢自动对焦,但更好.类似于亚马逊自动显示菜单的方式.
Is there a simple way of making the drop down list be displayed when user enters page? Like autofocus but better. Similar to how amazon displays it's menu automatically.
我知道我可能只可以制作一个ul下拉列表+ javascript等,但是想知道是否存在使用html或javascript进行选择的方法.
I understand that I could probably just make a ul dropdown list + javascript and etc, but was wondering whether there was a way of doing it with select using html or javascript.
推荐答案
您可以使用j查询来做到这一点(但我认为这并不是您真正需要的东西)
you can do it with j query(but i think it is not exactly some thing that you need)
HTML代码
<select class="select1" size="5" style="display:none">
<option name="test" value="" class="first">Select</option>
<option name="test" value="" class="">Opt1</option>
<option name="test" value="" class="">Opt2</option>
</select>
Java脚本
$(document).ready(function() {
$('.select1').toggle();
$(document).click(function(e) {
$('.select1').attr('size',0);
});
});
这篇关于使html选择选项下拉菜单默认打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!