I am creating a quiz and can't figure out why one of my submit buttons won't work.
Here is how the quiz works:
On page load, the questions appear, with possible answers. When the user selects an answer and clicks "Submit", he or she gets feedback on if the answer was correct. A new button, named "next" is presented at the bottom of the page. When it is clicked, the next question in my array should display.
Here is the problem:
The "next" button isn't doing anything when clicked. I set up an alert to test the "next" button, but it's not showing.
The on click function is set up exactly like the previous one, which is working. I'm stumped.
Here is my JSFiddle: http://jsfiddle.net/amykirst/3eubj/2/.
$(document).ready(function() {
showQuestion();
// When user clicks submit, grade the question
$("input[name='submit']").click(function() {
//alert("line 118: I clicked on submit");
gradeQuestion();
});
// When user clicks "Next Question", show next question
$("input[name='next']").click(function() {
alert("line 124: I clicked on next");
// update currentQuestion to next question
currentQuestion++;
//show question
showQuestion();
});
// Prevent form from refreshing page
$("form").submit(function(e) {
e.preventDefault();
});
}); // end document ready