【发布时间】:2015-02-24 01:06:02
【问题描述】:
我正在开发一个简单的测验应用程序,现在我向它添加了一个返回按钮,允许用户返回并更改他的答案。对于已经回答的问题,我想显示选中的单选按钮。我找到了一个答案here,但它对我不起作用。
这是我的 HTML:
<h1>Choose one of the following answers:</h1>
<h2 id="question">Question</h2>
<div id="form">
<input type="radio" name="Answer" value="0">
<label for="a1" id="a1">Answer 1</label>
<br>
<input type="radio" name="Answer" value="1">
<label for="a2" id="a2">Answer 2</label>
<br>
<input type="radio" name="Answer" value="2">
<label for="a3" id="a3">Answer 3</label>
<br>
<input type="radio" name="Answer" value="3">
<label for="a4" id="a4">Answer 4</label>
<br>
<input type="submit" value="Back" id="prev" class="button">
<input type="button" value="Next" id="next" class="button">
</div>
首先我想将之前选中的单选按钮的值存储在一个单独的数组中,但事实证明这太麻烦了。所以我想知道是否有一种简单的方法可以用 JS 或 jQuery 来完成?
【问题讨论】:
标签: javascript jquery radio-button