我有一个在JS中创建的测验系统。我正在使用输入元素来显示每个测验选项。我试图使它,所以当你点击提交时,它将循环遍历每个输入元素,如果输入文本是正确的答案,则将输入文本的样式设置为绿色,如果它是一个不正确的答案,则设置为红色。但是,我实际上很难获得输入值旁边的文本。
下面是测验的图片:https://gyazo.com/1ba5245de2c5c6f96bd728e31aeb0899
网页:
<!DOCTYPE html>
<html>
<head>
<link href ="style.css" rel ="stylesheet">
<!-- <link href="https://fonts.googleapis.com/css?family=OpenSans" rel="stylesheet"> -->
<script src = "main.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h1>Chapter 1 Quiz</h1>
<form id = "quiz" name = "quiz">
<p class = "questions">What is the capital of Rhode Island?</p>
<input id = "textbox" type = "text" name = "question1">
<p class = "questions">What is the capital of Connecticut?</p>
<input type = "radio" id = "mc" name = "question2" value = "Hartford"> Hartford<br>
<input type = "radio" id = "mc" name = "question2" value = "Heartford"> Heartford<br>
<p class = "questions">What is the capital of New York?</p>
<input type = "radio" id = "mc" name = "question3" value = "Albany"> Albany<br>
<input type = "radio" id = "mc" name = "question3" value = "All Benny's"> All Benny's<br>
<input id = "button" type = "button" value = "Finish" onclick = "check();">
</form>
<div id = "after_submit">
<p id = "number_correct"></p>
<p id = "message"></p>
</div>
</html>
</body>
SMILET
不负相思意
吃鸡游戏
相关分类