HTML form readonly SELECT tag/input

前端 未结 30 2793
陌清茗
陌清茗 2020-11-22 08:28

According to HTML specs, the select tag in HTML doesn\'t have a readonly attribute, only a disabled attribute. So if you want to keep

30条回答
  •  迷失自我
    2020-11-22 09:08

    Simple CSS solution:

    select[readonly]{
        background: #eee;
        cursor:no-drop;
    }
    
    select[readonly] option{
        display:none;
    }
    

    This results in Select to be gray with nice "disable" cursor on hover
    and on select the list of options is "empty" so you can not change its value.

提交回复
热议问题