I have a quiz I am making.
Some questions have multiple answers.
My html is as:
<div>Which problems equal 4?</div>
<input type="checkbox" id="qid" class="checks" data-correct="yes">2 + 2<br />
<input type="checkbox" id="qid" class="checks" data-correct="no">2 - 2<br />
<input type="checkbox" id="qid" class="checks" data-correct="yes">2 * 2<br />
I would like to alert if checked answers are both wrong or right.
Currently, my Javascript looks like this:
function checkMsResults(){
var result = $('input[name="qid"]:checked').attr("data-correct");
if(result == '1'){
result = "Answer is Correct";
}
else if(result == '0'){
result = "Answer is Not Correct";
}
else{
result = "Please make a selection";
}
alert(result + ".");
}
This will alert only one selection. Can someone teach me how to loop through each on so I can alert multiple selections?