How to disable/enable input field on click with jQuery

后端 未结 7 784
慢半拍i
慢半拍i 2020-12-31 13:36

How to properly enable/disable input field on click with jQuery?

I was experimenting with:

$(\"#FullName\").removeAttr(\'disabled\');
7条回答
  •  一向
    一向 (楼主)
    2020-12-31 14:26

    $("#FullName").prop('disabled', true);
    

    Will do.

    But keep in mind after you disable it (by the above code) onclick handler wont work as its disabled. To enable it again add $("#FullName").removeAttr('disabled'); in the onclick handler of another button or field.

提交回复
热议问题