I've made a quiz-creator, but now I'm trying to pull out the information made in that into the "frontend" quiz.
I'm trying to build a for loop like this. And also here trying to add the class '.hide' to all the divs with class '.question-holder' except the First created one.
for(var i = 0; i < questions.length; i++)
{
var q = questions[i];
var answers = q.getAnswers();
$(".question-holder").append("<h2 id='QuizQuestionHeadline'>" + q.getQuestion() + "</h2><div class='question-wrap'></div>");
$(".question-wrap").append("<ul class='answers' id='quiz-answers'></ul>");
for(var n = 0; n < answers.length; n++)
{
$("#quiz-answers").append("<li><input tabindex='1' type='checkbox' id='input-1'><label for='input-1'><span>"+ answers[n].getAnswer() +"</span></label></li>");
};
};
for(var i = 2; i < questions.length; i++)
{
$(".question-holder").addClass('hide');
};
Where the final HTML created by the above code should be:
<div class="question-holder">
<h2 id='QuizQuestionHeadline'>The Question</h2>
<ul id='quiz-answers' class="answers">
<li>
<input tabindex="1" type="radio" id="input-1" name="quiz-radio">
<label for="input-1"><span>Answer 1</span></label>
</li>
<li>
<input tabindex="2" type="radio" id="input-2" name="quiz-radio" checked>
<label for="input-2"><span>Answer 2</span></label>
</li>
</ul>
</div>
Anyone here that could help me out a bit? :)