javascript - 当我第二次运行我的应用程序时没有显示结果

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

最佳答案

在你的 var buttonAction = function() { 你正在做 showResult.hide(); 在你点击“Play Again”后它设置为 显示:无

但是,您永远不会在 showResults() 函数中调用 showResult.show();。所以它仍然是 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');
};

关于javascript - 当我第二次运行我的应用程序时没有显示结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19412706/

相关文章:

html - CSS:仅将滚动条添加到页面的 "content"部分

javascript - amCharts 中的标签旋转无法正常工作

javascript - 对于连接速度较慢的用户,我想用图像标签替换视频标签

php - 使用 PHP 在选项标签中编辑数据库

javascript - 将查询字符串设置为 ajax 数据

javascript - Google map Iframe 中隐藏的 <div> 缩放和居中问题

javascript - 一个html中有很多div

JavaScript 倒计时

javascript - 使用 RegExp 在模式中查找模式的多个实例

javascript - 没有 jQuery 和光标绘图的交互式 javascript 图表