<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery.min.js"></script>
</head>
<body>
<div class="checkbox">
<input type="checkbox"/>
</div>
<div class="checkbox">
<input type="checkbox"/>
</div>
<div class="checkbox">
<input type="checkbox"/>
</div>
<div class="checkbox">
<input type="checkbox"/>
</div>
<div class="checkbox">
<input type="checkbox"/>
</div>
<div class="checkbox">
<input type="checkbox"/>
</div>
<script type="text/javascript">
$(function(){
$(‘.checkbox‘).find(‘input‘).click(function(){
if($("input[type=checkbox]:checked").length >= 6)
{
$(this).removeAttr("checked");
alert("最多选5个!")}
});
})
</script>
时间: 2024-10-04 00:17:01