简体   繁体   中英

Hide the selected value in the box for a drop down list HTML

I was wondering if anyone knows how to always hide the selected text in the box of a drop down list. I want all options to show in the actual drop down, but i want the text in the box to be not visible. The DDL is generated using the HTML helper in c# in MVC framework.

@(Html.DropDownListFor(m => m.SelectedReadingsFilter, Model.FilterReadings, new {@onchange = "SubmitForm();", @class = "toolbar-button", @style= "top: -3px; cursor: pointer;" }))

Can we set that text's colour to transparent or something like that?

Thanks!

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

Just add "" after the model. Normally we put "-select-"

Html.DropDownListFor(m => 
m.SelectedReadingsFilter, 
Model.FilterReadings,"", new 
{@onchange = "SubmitForm();", @class 
= "toolbar-button", @style= "top: 
-3px; cursor: pointer;" }))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM