Home > Article > Web Front-end > How to Disable and Enable HTML Input Buttons Using JavaScript and jQuery?
Disabling and enabling HTML input buttons is essential for managing user interactions. Here's how you can achieve this:
Disable the button:
document.getElementById("Button").disabled = true;
Enable the button:
document.getElementById("Button").disabled = false;
For jQuery versions prior to 1.6:
Disable the button:
$('#Button').attr('disabled','disabled');
Enable the button:
$('#Button').removeAttr('disabled');
For jQuery versions 1.6 and later:
Disable the button:
$('#Button').prop('disabled', true);
Enable the button:
$('#Button').prop('disabled', false);
By controlling the disabled property, you can toggle the button's state to suit your application's needs.
The above is the detailed content of How to Disable and Enable HTML Input Buttons Using JavaScript and jQuery?. For more information, please follow other related articles on the PHP Chinese website!