第一种
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>checked</title>
<script type="text/javascript" src='http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js'></script>
</head>
<body>
<form>
<input type='checkbox' >
<input type='checkbox' >
<input type='checkbox' >
<input type='checkbox' >
<input type='checkbox' >
</form>
</body>
<script type="text/javascript">
$(":checkbox").on("change",function(){
var $checkbox = $(this);
console.log($('input:checked').length);
});
</script>
</html>
可以实时监听页面上有几个checkbox的值是checked