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.
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.
The default value of the select element can be set by using the 'selected' attribute on the required option. This is a boolean attribute. The option that is having the 'selected' attribute will be displayed by default on the dropdown list.
To stop the dropdown menu from closing: Set a break point on the parent node of the dropdown menu.
The <select> element creates the dropdown menu. It contains two attributes, name and id. The id attribute should have the same values as the for attribute in the <label> tag. The name attribute is used to identify the dropdown if the selection is being submitted in a form.
The <select> element is used to create a drop-down list. The <select> element is most often used in a form, to collect user input. The name attribute is needed to reference the form data after the form is submitted (if you omit the name attribute, no data from the drop-down list will be submitted).
you can do it with j query(but i think it is not exactly some thing that you need)
Html Code
<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 script
$(document).ready(function() {
$('.select1').toggle();
$(document).click(function(e) {
$('.select1').attr('size',0);
});
});
Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With