disable button in javascript code example

Example 1: javascript disable button

//disable the button
document.getElementById(BUTTON_ID).disabled = true;
//reable the button
document.getElementById(BUTTON_ID).removeAttribute('disabled');

Example 2: javascript how to disable a button

//Using Javascript
//Disabling a html button

document.getElementById("Button").disabled = true;
//Enabling a html button

document.getElementById("Button").disabled = false;


//Using jQuery
//Disabling a html button

$('#Button').attr('disabled','disabled');
//Enabling a html button

$('#Button').removeAttr('disabled');

Example 3: html button disabled

<button type="button" disabled>This button is disabled</button>

Example 4: javascript disable button

document.getElementById(BUTTON_ID).disabled = true;

Example 5: disable input type button in html

<input type="button" disabled value="Submit">

Example 6: enable html button

$('#Button').prop('disabled', true);