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?
Asked
Active
Viewed 96 times
-2
-
What you've already done? Show your code, put a code snippet / jsfiddle / codepen.... – Dinei May 20 '15 at 23:48
1 Answers
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