Drop-down list without selection

Is there a way to have a dropdown in which you cannot select items? So basically, I just want to use it as a way to show / hide the list. I do not want the backlight to freeze, and I do not want to change the selected item.

Could you suggest whether this is possible, or if anyone has any other ideas for achieving something like this, could you give me a good example.

thanks

+4
source share
2 answers

The optgroup tag comes to mind. It has a disabled attribute.

 <select> <optgroup label="My List" disabled> <option value="item1">Item 1</option> <option value="item2">Item 2</option> </optgroup> </select>โ€‹ 

However, IE 6 and 7 do not respect disabled . Arrgh. They also do not listen to the readonly attribute, marked generally by select .

You will have to add a reserve onchange="this.value ='item1';" for these browsers, which is obviously not waterproof if JavaScript is disabled.

Jsfiddle here

+7
source

Is there a way to have a dropdown in which items cannot be selected?

I have the same requirement. I liked it so much

 <select > <option value="item1" disabled>Item 1</option> <option value="item2" disabled>Item 2</option> <option value="item3" disabled>Item 3</option> <option value="item4" disabled>Item 4</option> </select> 

In jsfiddle

0
source

All Articles