user2612619
user2612619

Reputation: 1129

Button not being enabled

So I have a few buttons which look like this, the other three are exactly the same but with different text and ID.

<p id="a"> Counters on A: 0 </p> <button onclick="add('a')" disabled>Add</button>

I initially have the buttons disabled, but would like to enable them after button X1 is clicked. At the end of the function that is called when X1 is clicked I add the following lines

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

For some reason the buttons are still disabled. And I did a few tests and the program reaches before and after the enabling of the method but that one line is not being enabled. Why is this?

Upvotes: 0

Views: 68

Answers (2)

Gladiator Boo
Gladiator Boo

Reputation: 189

You assigned an id "a" to the < p > element, not the button.

Upvotes: 1

Christian Fritz
Christian Fritz

Reputation: 21364

<p> Counters on A: 0 </p> <button onclick="add('a')" disabled id="a">Add</button>

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

Upvotes: 1

Related Questions