Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make html select option drop down menu open by default

Tags:

html

selection

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.

like image 527
user81779 Avatar asked Apr 05 '13 06:04

user81779


People also ask

How do I set a default drop-down list?

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.

How do you keep a dropdown open while styling?

To stop the dropdown menu from closing: Set a break point on the parent node of the dropdown menu.

Can you make a drop down menu in HTML?

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.

How do I make a drop-down list selection in HTML?

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).


1 Answers

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

like image 143
KF2 Avatar answered Nov 15 '22 13:11

KF2