<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>复选框checkbox类似单选按钮radio</title>
</head>
<body>
<form method=post action="">
<input type="checkbox" name="aa" οnclick="bb(this)">
<input type="checkbox" name="aa" οnclick="bb(this)">
<input type="checkbox" name="aa" οnclick="bb(this)">
<input type="checkbox" name="aa" οnclick="bb(this)">
<input type="checkbox" name="aa" οnclick="bb(this)">
</form>
<script src="js/jQuery-2.2.0.min.js"></script>
<script type="text/javascript">
function bb(obj){
var aa = document.forms[0].aa;
for (var i = 0; i < aa.length; i++) {
aa[i].checked = false;
}
obj.checked = true;
}
</script>
</body>
</html>
转载于:https://www.cnblogs.com/xumqfaith/p/6645216.html