codingtcher.com
Theme Night
Home
Login

How to disable a button in jquery

//jquery disabled to button
$( "button" ).prop( "disabled", true );
$("#button").attr("disabled", true);

//jquery remove disabled property from button
$('#edit').click(function(){ // click to
            $('.inputDisabled').attr('disabled',false); // removing disabled in this class
 });

//or
$("#edit").click(function(event){
   event.preventDefault();
   $('.inputDisabled').prop("disabled", false); // Element(s) are now enabled.
});

//jquery button remove disabled attribute
//for a class
$('.inputDisabled').prop("disabled", false);
//for a ID
$('#inputDisabled').prop("disabled", false);

//jquery disable button
$('.class').prop("disabled", true);
$('#id').prop("disabled", true);

// As function
const disable = (id) => $(`#${id}`).prop("disabled", true);

Related Code