The user clicks in order on button 1, 2, and lastly 3. After user clicks on button 3 a "congrats" box pops up, which is working fine.
When user clicks on button 1 the background of that button should turn grey, but button 2 and 3 should still be blue. Then when user clicks on button 2 it should turn grey just like button 1 is already grey and button 3 should still be blue. Then after user clicks on button 3 all buttons should be grey and the "congrats" box appears.
Right now they all stay blue until I click button 3. How to change that?
$(document).ready(function() {
$('#button-1').click(function () {
$('#button-2').click(function () {
$('#button-3').click(function () {
$('.button').css({background: 'grey'});
$('#congrat-box').fadeIn(1200);
});
});
});
});
.button {
height: 30px;
width: 30px;
border-radius: 12px;
background: blue;
color: gold;
border: 1px solid white;
box-shadow: 0 0 3px grey;
}
#congrat-box {
background: orange;
font-size: 24px;
line-height: 50px;
padding: 20px;
text-align: center;
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<button id="button-1" class="button">1</button>
<button id="button-2" class="button">2</button>
<button id="button-3" class="button">3</button>
<div id="congrat-box">Congrats!!!</div>
Provided snack snippet above, but here is a FIDDLE if you prefer that.