Disabling and Enabling a Html Input Button

So I have a button like this:

<input id="Button" type="button" value="+" style="background-color:grey" onclick="Me();"/>

How can I disable and enable it when I want? I have tried disabled="disable" but enabling it back is a problem. I tried setting it back to false but that didn't enable it.

2

12 Answers

Using Javascript

  • Disabling a html button

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

    document.getElementById("Button").disabled = false;
    
  • Demo Here


James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.