转到下一个数组值失败

时间:2016-09-01 17:55:02

标签: javascript jquery html arrays

我创建了一个js测验。问题存储在jquery数组中。但是,单击next将不会进入下一个数组值。如何解决这个问题?

function nextQuestion() {

    submt = true;
    $('#explanation').empty();
    $('#question').append(quiz[currentquestion]['question']).html();
    if (quiz[currentquestion].hasOwnProperty('image') && quiz[
        currentquestion]['image'] != "") {
        if ($('#question-image').length == 0) {
            $(document.createElement('img')).addClass(
                'question-image').attr('id',
                'question-image').attr('name', 'anscho').attr(
                'src', quiz[currentquestion]['image']).attr(
                'alt', htmlEncode(quiz[currentquestion][
                    'question'
                ])).insertAfter('#question');
        } else {
            $('#question-image').attr('src', quiz[
                currentquestion]['image']).attr('alt',
                htmlEncode(quiz[currentquestion]['question'])
            );
        }
    } else {
        $('#question-image').remove();
    }
    addChoices(quiz[currentquestion]['choices']);
    setupButtons();
}

1 个答案:

答案 0 :(得分:0)

解决了它。感谢Johnny Mopp指出currentquestion应该增加。感谢!!!