jquery判断checkbox最多选几个

论坛 期权论坛 脚本     
匿名技术用户   2021-5-2 21:52   282   0

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

转载于:https://www.cnblogs.com/qq309240790/p/5127567.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP