jQuery 获取选定单选按钮的值 [英] jQuery get value of selected radio button

查看:39
本文介绍了jQuery 获取选定单选按钮的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题陈述很简单.我需要查看用户是否从单选组中选择了一个单选按钮.组中的每个单选按钮共享相同的 ID.

The problem statement is simple. I need to see if user has selected a radio button from a radio group. Every radio button in the group share same id.

问题是我无法控制表单的生成方式.以下是单选按钮控件代码的示例代码:

The problem is that I don't have control on how the form is generated. Here is the sample code of how a radio button control code looks like:

<input type="radio" name='s_2_1_6_0' value='Mail copy to my bill to address' id = "InvCopyRadio" onchange = 'SWESubmitForm(document.SWEForm2_0,s_4,"","1-DPWJJF")' style="height:20;width:25" tabindex=1997 >

In addition to this when a radio button is selected it doesn't add a "checked" attribute to the control just text checked (I guess just the property checked without a value).下面是选定的无线电控件的样子

In addition to this when a radio button is selected it doesn't add a "checked" attribute to the control just text checked (I guess just the property checked without a value). Below is how a selected radio control looks like

<input type="radio" checked name='s_2_1_6_0' value='Mail copy to my bill to address' id = "InvCopyRadio" onchange = 'SWESubmitForm(document.SWEForm2_0,s_4,"","1-DPWJJF")' style="height:20;width:25" tabindex=1997 >

任何人都可以帮助我使用 jQuery 代码来帮助我获取选中单选按钮的值吗?

Can anybody help me with jQuery code that can help me to get the value of checked radio button?

推荐答案

使用即可.

$('input[name="name_of_your_radiobutton"]:checked').val();

就是这么简单.

这篇关于jQuery 获取选定单选按钮的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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