单个单选框radio 点击选中点击取消选中

$("input:radio").click(function(){
var domName = $(this).attr('name');//获取当前单选框控件name 属性值
var checkedState = $(this).attr('checked');//记录当前选中状态
$("input:radio[name='" + domName + "']").attr('checked',false);//1.
$(this).attr('checked',true);//2.
if(checkedState == 'checked'){
$(this).attr('checked',false); //3.
}
});

猜你喜欢

转载自www.cnblogs.com/thybk/p/8950675.html