<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<div>
<input type="checkbox" name="fruit"> apple
<input type="checkbox" name="fruit"> orange
<input type="checkbox" name="fruit"> banana
<input type="checkbox" name="fruit"> watermelon<br>
<input type="button" value="I like these fruit!">
</div>
<script>
$(function(){
$("input[type='button']").click(function() {
alert($("input[type='checkbox']:checked").length);
});
})
</script>
</body>
</html>