Can HTML checkboxes be set to readonly?

前端 未结 30 2067
無奈伤痛
無奈伤痛 2020-11-22 08:39

I thought they could be, but as I\'m not putting my money where my mouth was (so to speak) setting the readonly attribute doesn\'t actually seem to do anything.

I\'d

30条回答
  •  一个人的身影
    2020-11-22 08:57

    Building on the above answers, if using jQuery, this may be an good solution for all inputs:

    
    

    I'm using this with Asp.Net MVC to set some form elements read only. The above works for text and check boxes by setting any parent container as .readonly such as the following scenarios:

提交回复
热议问题