Quiz được ứng dụng trong rất nhiều trường hợp khác nhau. Bạn có thể tạo một quiz theo bộ mã sau đây:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Quiz</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<form name = "quizQ1">
<b>Question 1: In which country was the first Table Tennis patent filed?</b><br> <br>
<input type = "radio" name = "quiztest" onclick = "getAnswer('a')"> United Kingdom <br>
<input type = "radio" name = "quiztest" onclick = "getAnswer('b')"> United States <br>
<input type = "radio" name = "quiztest" onclick = "getAnswer('c')"> France <br>
<input type = "radio" name = "quiztest" onclick = "getAnswer('d')"> Turkey <br><br><br>
</form>
</div>
<script type = "text/javascript">
function getAnswer(input) {
if (input == "a") {alert ("Well done! The first Table Tennis Patent was issued in England on the 15th of July 1890.")}
else {alert ("No that's incorrect, please try again...")}
}
</script>
</body>
</html>
Demo