Home  »  CodeProgrammingSnippetsTechnology   »   How to Use jQuery to Disable and Enable an HTML Input

How to Use jQuery to Disable and Enable an HTML Input

Posted: August 3, 2022 | by Site Host

With jQuery 1.6+ use the following syntax to disable and enable the HTML input:

$("#inputID").prop('disabled', true); //disable 
$("#inputID").prop('disabled', false); //enable

Those still on jQuery 1.5 and below use this to disable and enable the HTML input:

$("#inputID").attr('disabled','disabled'); //disable 
$("#inputID").removeAttr('disabled'); //enable

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

See also  Nginx Redirect www to non-www and non-www to www