当我第二次运行我的应用程序时,结果未显示

时间:2013-10-16 20:02:49

标签: javascript jquery html css

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

//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/

1 个答案:

答案 0 :(得分: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'); }; 即可。

{{1}}