input 获取 radio 选中的值

1、方式一:var timeSlotId=$("input[type='radio']:checked").val();

方式二:var regionId=$('input[id="region"]').filter(':checked').val(); //通过input Id获取

方法三:$("input[name='items']:checked").val(); //通过input name获取

2、

2.设置第一个Radio为选中值:
$('input:radio:first').attr('checked', 'checked');
或者
$('input:radio:first').attr('checked', 'true');
注:attr("checked",'checked')= attr("checked", 'true')= attr("checked", true)
3.设置最后一个Radio为选中值:
$('input:radio:last').attr('checked', 'checked');
或者
$('input:radio:last').attr('checked', 'true');
4.根据索引值设置任意一个radio为选中值:
$('input:radio').eq(索引值).attr('checked', 'true');索引值=0,1,2....

你可能感兴趣的:(input 获取 radio 选中的值)