期望的情况:所有的测验内容从一开始就被隐藏了,我有一个带有 li 项目的 ul 列表作为我的“测验问题导航”,它应该一次显示 1 个测验问题(带有无线电 btns 选项和 div 响应)单击“问题导航”时。
当前情况:我正在考虑使用一个数组来检查相同的 attr 名称“qns1”,但我不熟悉 JavaScript 语法
Javascript
$(".span9").hide();
HTML
<ul class="quiznav">
<li>Q1</li><br>
<li>Q2</li><br>
<li>Q3</li><br>
</ul>
<div class="span9">
<div class="qnstitle" name="qns1">Q1. Lorem ipsum dolor sit amet</div>
<label class="radio">
<input name="qns1" class="radioBtn" type="radio" value="A">a) asdf
</label>
<div class="resp" data-qns="qns1">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris aliquet ligula mi. Aenean eu magna quam. In ultrices nisi non tellus molestie ut mattis turpis convallis. </p>
</div>
<label class="radio">
<input name="qns1" class="radioBtn" type="radio" value="B">b) bsdf
</label>
<div class="resp" data-qns="qns1">
<p>Proin porta, ante eu feugiat facilisis, nulla erat porta dui, sed pellentesque orci sapien quis libero. Nam nec nibh metus, nec luctus massa.</p>
</div>
<label class="radio">
<input name="qns1" class="radioBtn" type="radio" value="C">c) csdf
</label>
<div class="resp" data-qns="qns1">
<p>Donec metus nibh, pharetra vitae semper id, blandit non lorem. Fusce ut metus a dui egestas congue quis quis augue. Suspendisse sed nunc sed nulla volutpat pharetra at vel purus.</p>
</div>
<br>
<div class="qnstitle" name="qns2">Q2. Nunc sed aliquet enim.</div>
<label class="radio">
<input name="qns2" class="radioBtn" type="radio" value="A">a) azzzddsaf
</label>
<div class="resp" data-qns="qns2">
<p>Donec metus nibh, pharetra vitae semper id, blandit non lorem.</p>
</div>
<label class="radio">
<input name="qns2" class="radioBtn" type="radio" value="B">b) bzzzzddafdsf
</label>
<div class="resp" data-qns="qns2">
<p>Aenean eu metus id dui tristique aliquam. Pellentesque non scelerisque nisi. Integer a nibh orci</p>
</div>
<label class="radio">
<input name="qns2" class="radioBtn" type="radio" value="C">c) czzdfasdf
</label>
<div class="resp" data-qns="qns2">
<p>Pellentesque turpis libero, consectetur nec dictum eu, accumsan a sapien. Integer eget ultrices risus. Pellentesque vel orci purus.</p>
</div>
<div class="qnstitle" name="qns3">Q3. Nunc sed aliquet enim.</div>
<label class="radio">
<input name="qns3" class="radioBtn" type="radio" value="A">a) azzzddsaf
</label>
<div class="resp" data-qns="qns3">
<p>Donec metus nibh, pharetra vitae semper id, blandit non lorem.</p>
</div>
<label class="radio">
<input name="qns3" class="radioBtn" type="radio" value="B">b) bzzzzddafdsf
</label>
<div class="resp" data-qns="qns3">
<p>Aenean eu metus id dui tristique aliquam. Pellentesque non scelerisque nisi. Integer a nibh orci</p>
</div>
<label class="radio">
<input name="qns3" class="radioBtn" type="radio" value="C">c) czzdfasdf
</label>
<div class="resp" data-qns="qns3">
<p>Pellentesque turpis libero, consectetur nec dictum eu, accumsan a sapien. Integer eget ultrices risus. Pellentesque vel orci purus.</p>
</div>
</div><!-- end of span9 -->