JQuery操作CheckBox和Radio

<input type="checkbox" id="dx">多选框
<input type="radio" name="select" value=1>单选1
<input type="radio" name="select" value=2>单选2
<input type="radio" name="select" value=3>单选3

 

一、判断CheckBox是否选中

var isChecked = $('#dx').is(':checked');//选中返回true,未选中返回false

二、获取Radio的选中值

var checkValue = $('input[name="select"]:checked').val();

三、设置CheckBox的勾选状态

$('#dx').attr('checked',true)

四、设置Radio选中

$('input[name="select"]:eq(1)').attr('checked',true);
$('input[name="select]').eq(1).attr('checked',true);


 

 

转载于:https://www.cnblogs.com/ecosu/p/4588079.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值