jq版本的checkbox有radio的单选效果(可得到value值)

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>复选框checkbox类似单选按钮radio</title>
</head>
<body>
<form method=post action="">
<input type="checkbox" name="aa" value="1">
<input type="checkbox" name="aa" value="2">
<input type="checkbox" name="aa" value="3">
<input type="checkbox" name="aa" value="4">
<input type="checkbox" name="aa" value="5">
</form>
<script src="js/jQuery-2.2.0.min.js"></script>
<script type="text/javascript">
$('input').click(function(){
var aa = document.forms[0].aa;
for(var i=0;i<aa.length;i++){
aa[i].checked=false;
}
this.checked=true;
console.log(this.value);
});
</script>
</body>
</html>

原文地址:https://www.cnblogs.com/xumqfaith/p/6645403.html