<!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>

相关文章:

  • 2022-01-19
  • 2022-01-18
  • 2021-06-22
  • 2022-12-23
  • 2021-10-09
猜你喜欢
  • 2022-12-23
  • 2021-09-15
  • 2022-12-23
  • 2021-06-11
  • 2022-03-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案