How can I use jQuery to make an input readonly?

后端 未结 13 2181
挽巷
挽巷 2020-12-07 09:54

I have the following input:

  

How c

13条回答
  •  旧巷少年郎
    2020-12-07 10:48

    To make an input readonly use:

     $("#fieldName").attr('readonly','readonly');
    

    to make it read/write use:

    $("#fieldName").removeAttr('readonly');
    

    adding the disabled attribute won't send the value with post.

提交回复
热议问题