<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- 引入JQuery -->
<script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
<ul>
<li>
</li>
<input type="checkbox" value="橘子" name="check">橘子1</input>
<li>
<input type="checkbox" value="香蕉" name="check">香蕉1</input>
</li>
</ul>
<input type="button" value="方法1" id="b1">
<input type="button" value="方法2" id="b2">
</body>
<script>
//方法1
$("#b1").click(function(){
//$('input:checkbox:checked') 等同于 $('input[type=checkbox]:checked')
//意思是选择被选中的checkbox
$.each($('input:checkbox:checked'),function(){
window.alert("你选了:"+
$('input[type=checkbox]:checked').length+"个,其中有:"+$(this).val());
});
});
//方法2
$("#b2").click(function(){
$.each($('input:checkbox'),function(){
window.alert("你选了:"+
$('input[type=checkbox]:checked').length+"个,其中有:"+$(this).val());
});
});
</script>
</html>