-2

I have two buttons. I want the second button to be disabled until the first button is clicked. How can I do this with JavaScript and CSS?

Ernest
  • 98
  • 7

1 Answers1

0

Here you go

document.getElementById('btn1').addEventListener('click', function() {
    document.getElementById("btn2").disabled = false;
});

HTML:

<input type="button" id="btn1" value="button 1" />
<input type="button" disabled="disabled" id="btn2" value="button 2" />

Tested in Chrome.

Fiddle: http://jsfiddle.net/b41oskm4/

garryp
  • 5,508
  • 1
  • 29
  • 41