简体   繁体   English

如何为测验应用程序创建重启按钮?

[英]How to create a restart button for a quiz app?

This is a sample I got from the web. I want to create a restart button for the quiz.这是我从 web 获得的示例。我想为测验创建一个重新启动按钮。 How am I suppose to do that?我该怎么做? If possible, please include a Codepen demo too.如果可能,请也包含一个 Codepen 演示。 Thank you !!谢谢 !!

Codepen Demo代码笔演示

var all_questions = [{
  question_string: "What is my name?",
  choices: {
    correct: "James",
    wrong: ["John", "Bob", "Jeff"]
  }
}]

Add below lines after submit button click event.在提交按钮单击事件后添加以下行。

// Add listener for the restart button
$('#restart-button').click(function() {
  current_question_index = 0;
  change_question();
});

See the demo here: Codepen在此处查看演示: Codepen

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM