Get radio checked in an array in jquery(在 jquery 的数组中检查收音机)
本文介绍了在 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 的数组中检查收音机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:在 jquery 的数组中检查收音机


基础教程推荐
猜你喜欢
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01