查找尚未选中的所有广播组 [英] Find all radio groups which haven't been selected

查看:60
本文介绍了查找尚未选中的所有广播组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我正在处理的基本测验/调查类型的应用程序,如果他们没有回答所有问题,我想在提交之前给用户提示。所有问题都是使用单选按钮的多种选择:

I have a basic quiz/survey type application I'm working on, and I'd like to give the user a prompt before they submit if they haven't answered all the questions. All the questions are multiple choice using radio buttons:

<div class="question">
    Q1: What is the second letter of the alphabet?
    <div class="choices">
        <input type="radio" name="question_1" value="1" /> A
        <input type="radio" name="question_1" value="2" /> B
        <input type="radio" name="question_1" value="3" /> C
    </div>
</div>
<div class="question">
    Q2: Which out of these is a berry?
    <div class="choices">
        <input type="radio" name="question_2" value="1" /> Apples
        <input type="radio" name="question_2" value="2" /> Bananas
        <input type="radio" name="question_2" value="3" /> Carrots
    </div>
</div>
<div class="question"> ...etc

如何找到哪些群组没有勾选期权?或者至少,如果还有哪些没有被回答?

How do you find which groups haven't got an option ticked? Or at least, if there are any which haven't been answered?

jQuery没问题,甚至是首选。

jQuery is ok, and even preferred.

推荐答案

啊,我想通了:

$('div.question:not(:has(:radio:checked))')

这篇关于查找尚未选中的所有广播组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆