首页 > 其他 > 详细

checkbox限制选中个数

时间:2014-10-08 23:37:38      阅读:433      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<link href="sysStyle.css" type="text/css" rel="stylesheet"/>
<link href="../crm-css/search.css" type="text/css" rel="stylesheet"/>
<script src="jquery-1.7.2.js" type="text/javascript"></script>
<script type="text/javascript">

$(document).ready(function() {

 

$(‘input[type=checkbox]‘).click(function() {

$("input[name=‘apk[]‘]").attr(‘disabled‘, true);

if ($("input[name=‘apk[]‘]:checked").length >= 3) {

$("input[name=‘apk[]‘]:checked").attr(‘disabled‘, false);
alert("选中超过三个");

} else {

$("input[name=‘apk[]‘]").attr(‘disabled‘, false);

}

});

 

})

</script>

<ul>

<li>

<input type="checkbox" name="apk[]" value=1 />

APK1

</li>

<li>

<input type="checkbox" name="apk[]" value=2 />

APK2

</li>

<li>

<input type="checkbox" name="apk[]" value=1 />

APK3

</li>

<li>

<input type="checkbox" name="apk[]" value=4 />

APK4

</li>

<li>

<input type="checkbox" name="apk[]" value=6 />

APK5

</li>

<li>

<input type="checkbox" name="apk[]" value=7 />

APK6

</li>

<li>

<input type="checkbox" name="apk[]" value=8 />

APK7

</li>

</ul>

checkbox限制选中个数

原文:http://www.cnblogs.com/yy123/p/4011685.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!