在 jquery 的数组中检查收音机 [英] Get radio checked in an array in jquery

查看:34
本文介绍了在 jquery 的数组中检查收音机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了下一个 html 代码,我想得到选中的单选按钮数组:

I got the next html code and i want to get the array of checked radio buttons:

    <tr>
    <td>¿Cómo te llamas?</td>

    <td><input class="radio" type="radio" name="respuesta1" value="female"> Pablo</td>
    <td><input class="radio" type="radio" name="respuesta1" value="female"> Christian</td>
    <td><input class="radio" type="radio" name="respuesta1" value="female"> Alberto</td>


    </tr>

    <tr>
    <td>¿Cuánto es 2 + 2?</td>


    <td><input class="radio" type="radio" name="respuesta2" value="female"> 2</td>
    <td><input class="radio" type="radio" name="respuesta2" value="female"> 3</td>
    <td><input class="radio" type="radio" name="respuesta2" value="female"> 4</td>

    </tr>

如您所见,有两个问题,但我只想在 jquery 数组中获取已检查的收音机以获得正确答案.你能帮我么?

As you can see, there arte two questions but i want only get the checked radios in a jquery array for the correct answers. Can you please help me?

推荐答案

我觉得这可能行得通

$(".radio:checked").each(function() {
console.log($(this).val());
});

这篇关于在 jquery 的数组中检查收音机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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