开发者

How to disable a drop down list with CSS, so it appears grayed out?

I have an ASP.NET application with a drop down list. How to di开发者_JAVA技巧sable a drop down list with CSS, so it appears grayed out? Is it possible to do this with only CSS ?


I used pointer-events: none; and it works ok. You can even set opacity to gray it out. Create a class and add/remove it as you wish. Something like:

.disabled { opacity: 0.6; pointer-events: none; }

Note that the user might still be able to use keyboard and tab to it!!


David is right. Another option (still non-CSS) is too loop through all the options and disable each one. They will turn the gray color you want and be disabled. Using a library like jQuery makes this a snap.


It seems to me that this is almost the same question... That answer suggests using something similar to:

<asp:DropDownList ID="DropDownList1" runat="server" Enabled="False"> </asp:DropDownList>


CSS (Cascading Style Sheet) is made for changing style of elements, not functionality. You can do it using HTML: Enabled="False" for ASP.NET tags or by adding empty disabled attribute without value to simple HTML tags.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜