要使用jQuery设置radio按钮的选中状态,可以使用prop()方法或attr()方法。
1、使用prop()方法:
$('input[name="your_radio_name"]').prop('checked', true);
将"your_radio_name"替换为你的radio按钮的名称。
2、使用attr()方法:
$('input[name="your_radio_name"]').attr('checked', 'checked');
同样,将"your_radio_name"替换为你的radio按钮的名称。
这两种方法都可以将指定的radio按钮设置为选中状态。请注意,prop()方法是在jQuery版本1.6及更高版本中引入的,
而attr()方法在之前的版本中也可以使用。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: jquery设置radio选中状态的方法是什么