how to add disabled attribute in jquery code example

Example 1: jquery disable input

//jQuery 1.6+ use:
$("#inputID").prop('disabled', true); //disable 
$("#inputID").prop('disabled', false); //enable

//jQuery 1.5 and below use:
$("#inputID").attr('disabled','disabled'); //disable 
$("#inputID").removeAttr('disabled'); //enable

Example 2: using jquery how to add disabled to a html tag

$(element). prop('disabled', true);

Example 3: jquery enable textbox

// Disable #x
$( "#x" ).prop( "disabled", true );
 
// Enable #x
$( "#x" ).prop( "disabled", false );

Example 4: jquery toggle attribute disabled

$('#el').prop('disabled', function(i, v) { return !v; });

Tags:

Html Example