<!DOCTYPE>
<html>
<head>
<title>实现复选框的单选效果</title>
</head>
<body>
<form method=post action="">
<input type="checkbox" name="aa" onclick="bb(this)">
<input type="checkbox" name="aa" onclick="bb(this)">
<input type="checkbox" name="aa" onclick="bb(this)">
<input type="checkbox" name="aa" onclick="bb(this)">
<input type="checkbox" name="aa" onclick="bb(this)">
</form>
</body>
</html>
<script language="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>
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)