如何在jQuery中获取单选按钮列表的选定值? [英] How to get the selected value of the radio button list in jquery?

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

问题描述

我有一个单选按钮列表,其ID为值,我想访问jquery函数中的选定ID.

I have radio button list which has id as the value, I want to access the selected id in the jquery function.

推荐答案

如果您有这样的HTML:

If you have HTML that looks like this:

<input type='radio' name='choices' value='1'>
<input type='radio' name='choices' value='2'>
<input type='radio' name='choices' value='3'>
<input type='radio' name='choices' value='4'>
<input type='radio' name='choices' value='5'>

您将通过以下方式获得选定的单选值:

You would get the selected radio value with this:

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

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

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