-1

First, I will apologize for my lack of programming knowledge and ignorance. I am a graphic designer trying to create an AR experience, and I need some help with javascript to achieve the following:

I have 5 buttons. When each button is clicked, it launches a popup with some information. 2 of the buttons are "incorrect" answers, 3 of the buttons are "correct" answers. I want to be able to keep track of whether or not the 3 correct answers have been chosen, and if they have (in no particular order), I'd like to be able to show an end-image.

This needs to be done using javascript only, and I would be grateful if someone more knowledgeable than myself could show me how the code should look. I have seen lines of code that might be applicable, but I'm afraid I am unable to figure out show to string them together to achieve what I'd like.

Thankyou kindly, in advance for your time. Respectfully, Kimber

Kimber
  • 1

1 Answers1

0

All you really need is a simple way to keep track of what buttons need to be pressed and what have been pressed.

var m = $('#message');
m.hide();
$('.req').on('click', function() {
  $(this).removeClass('req');
  if ($('.req').length === 0) {
    m.show();
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input class="req" type="button" value="Button 1" />
<input class="req" type="button" value="Button 2" />
<input class="req" type="button" value="Button 3" />
<input type="button" value="Button 4" />
<input type="button" value="Button 5" />
<p id="message">Required buttons have been pressed.</p>
Etheryte
  • 24,589
  • 11
  • 71
  • 116