<html>
<head>
<!-- 引入JQuery -->
</head>
<body>
<input type="checkbox" value="橘子" name="check">橘子1</input>
<input type="checkbox" value="香蕉" name="check">香蕉1</input>
<input type="checkbox" value="西瓜" name="check">西瓜1</input>
<input type="checkbox" value="芒果" name="check">芒果1</input>
<input type="checkbox" value="葡萄" name="check">葡萄1</input>
<input type="button" value="方法1" id="b1">
<input type="button" value="方法2" id="b2">
</body>
<script type="text/javascript" src="jquery-2.2.2.min.js"></script>
<script type="text/javascript" src="h27.js"></script>
node2:/var/www/html/js#
node2:/var/www/html/js#cat h27.js
$("#b1").click(function(){
//$('input:checkbox:checked') 等同于 $('input[type=checkbox]:checked')
//意思是选择被选中的checkbox
$.each($('input:checkbox:checked'),function(){
window.alert("你选了:"+
$('input[type=checkbox]:checked'));
});
});