0

我有这个测验应用程序,它会在我第一次运行它时显示结果,但是当我再次单击播放并再次运行该应用程序时,它没有显示结果。我知道我在以下代码中有问题,但无法弄清楚。请帮忙 -

//This function is for reseting the quiz
    var resetQuiz = function() {
            if (resetCounter++ > 1 || quizOver || confirm('Are you sure you want to reset the quiz?')) {
                counter = 0;
                quizOver = false;
                results = {count: 0, answers: [], currentScore: 0};
                scoreNode.addClass('no_score').text('');
                questionBlock.show();
                nextQuestion();
            }
    };
    //This function handle the results
    var showResults = function() {
            answersBlock.empty();
            questionBlock.hide();
            showResult.text('You answered ' + results.currentScore + '% of '
                + 'the questions correctly.');
            quizOver = true;
            actionButton.text('Play again');
    };

完整的应用程序在这里 - http://jsfiddle.net/varunksaini/J5qVd/

4

1 回答 1

3

在您单击“再次播放”后,var buttonAction = function() {您正在执行的操作将其设置为showResult.hide();display:none

但是,您永远不会调用showResult.show();showResults() 函数。所以它仍然存在display:none。您只需要在showResults.show();更改文本后打电话。

var showResults = function() {
        answersBlock.empty();
        questionBlock.hide();
        showResult.text('You answered ' + results.currentScore + '% of '
            + 'the questions correctly.');
        quizOver = true;
        showResult.show(); //Show the results if they have been hidden
        actionButton.text('Play again');
};
于 2013-10-16T20:12:46.650 回答