使用jquery实现单选框、多选框取消选中状态

时间:2023-03-08 22:16:55
使用jquery实现单选框、多选框取消选中状态
function radioReset(){
/*方式一*/
/* var radios = $("input[type='radio']");
for (i=0; i<radios.length; i++){
if(radios[i].checked){
radios[i].checked = false;
}
} */
/*方式二*/
$("input[type='radio']").removeAttr('checked');
}

<input type="button" class="button_gray" value="重 填" onclick="radioReset();">

切记 :如果在input类型为reset的上面添加onclick="radioReset();"如:

<input type="reset" class="button_gray" value="重 填" onclick="radioReset();">

取消选中的js代码不生效