【发布时间】:2020-02-18 23:00:17
【问题描述】:
我有一个有效的测验,但一旦做出正确答案,它就会隐藏对先前问题的错误答案。我希望出现 6 个问题的结果,即使其中一些不正确。我讨厌重复相同的代码 6 次。
https://designaire.com/test1/health.html
<script>
$(function() {
$('.exp').hide();
$('.wrong').hide();
$('input[name="test"]').on('click', function() {
var el = $(this);
if (el.val() == 'ans') {
el.parents('.q').nextAll('.exp').first().show();
el.parents('.q').nextAll('.wrong').first().hide();
$('.wrong').hide();
} else {
el.parents('.q').nextAll('.wrong').first().show();
el.parents('.q').nextAll('.exp').first().hide();
}
})
});
</script>
<form class="q">
1. Janelle is excitedly telling her friend Reina how her job interview went. Reina keeps texting her boyfriend.
<div class="answer">
<input name="test" type="radio" value="inc" />
Respect
<input name="test" type="radio" value="ans" />
Disrespect
</div>
</form>
<div class="exp">★ Good Job!</div>
<div class="wrong">Take another look at the examples in this lesson.</div></div>
【问题讨论】:
标签: javascript jquery arrays google-form-quiz