如何使用jQuery检查单选按钮?我尝试用jQuery检查单选按钮。这是我的密码:<form>
<div id='type'>
<input type='radio' id='radio_1' name='type' value='1' />
<input type='radio' id='radio_2' name='type' value='2' />
<input type='radio' id='radio_3' name='type' value='3' />
</div></form>而JavaScript:jQuery("#radio_1").attr('checked', true);不起作用:jQuery("input[value='1']").attr('checked', true);不起作用:jQuery('input:radio[name="type"]').filter('[value="1"]').attr('checked', true);不起作用:你还有别的主意吗?我遗漏了什么?
3 回答

UYOU
TA贡献1878条经验 获得超4个赞
$("#radio_1").prop("checked", true);
$("#radio_1").attr('checked', 'checked');
提示:click()
change()

弑天下
TA贡献1818条经验 获得超8个赞
$("input[name=background][value='some value']").prop("checked",true);
添加回答
举报
0/150
提交
取消