How to disable/enable input field on click with jQuery

后端 未结 7 748
慢半拍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:09

    For jQuery version 1.6+ use prop:

    $('#elementId').click(function(){
            $('#FullName').prop('disabled', true\false);
    });
    

    For older versions of jQuery use attr:

    $('#elementId').click(function(){
            $('#FullName').attr('disabled', 'disabled'\'');
    });
    

提交回复
热议问题