且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在jQuery中获取单选按钮列表的选定值?

更新时间:2022-11-10 20:26:36

如果您有这样的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();