set disabled attribute javascript code example

Example 1: remove disabled attribute javascript

document.getElementById('my-input-id').disabled = false;

Example 2: howt to disable a select tag using js

document.getElementById("one").onchange = function () {
  document.getElementById("two").setAttribute("disabled", "disabled");
  if (this.value == 'car')
    document.getElementById("two").removeAttribute("disabled");
};

Example 3: javascript getelementbyid disable

//javascript getelementbyid disable
//Enable a button
document.getElementById("Button").disabled=false;

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

Tags:

Html Example