Two buttons move from question to question, my variable "actual" keeps account of what question I am on. I'd like to display this number on the screen in a div. Nothing appears at the moment and there is no error.
<script type="text/javascript">
var actual = 0; // select by default the first question
$(document).ready(function() {
var number_of_question = $('.question').length; // get number of questions
$('.question:gt(' + actual + ')').hide(); // Hide unselect question
$('#nextQ').click(function() {
if (actual < number_of_question - 1) {
changeQuestion(actual + 1); // display select question
}
});
$('#forwardQ').click(function() {
if (actual) {
changeQuestion(actual - 1); // display select question
}
});
});
function changeQuestion(newQuestion) {
$('.question:eq(' + actual + ')').hide(); // hide current question
$('.question:eq(' + newQuestion + ')').show(); // show new question
actual = newQuestion; // memorize actual selection
//alert(actual);
}
$('#question_number').html(actual);
</script>
<div class="digit" id="question_number"></div>