62,067
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<title></title>
<script src="js/jquery-1.5.1.js"></script>
<script>
$(function(){
$(".question div").each(function(){
var obj = $(this);
$("input[type='checkbox']", obj).click(function(){
if($("input[type='checkbox']:checked", obj).length > parseInt(obj.attr("max"))){
alert("max.");
return;
}
});
});
});
</script>
</head>
<body>
<div class="question">
<div max="3">
<input type="checkbox" name="question1"/>
....
</div>
<div max="4">
<input type="checkbox" name="question2"/>
....
</div>
</div>
</body>
</html>