<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="../js/jquery-3.5.1.js"></script>
<script>
$(function () {
//表单属性 伪类选择器
// :checked
$("#btn1").click(function () {
var result = $("input:checked").val();
window.alert(result);
});
});
</script>
</head>
<body>
<p>喜欢的水果:
<input type="checkbox" id="apple" value="苹果"><label for="apple">苹果</label>
<input type="checkbox" id="watermelon" value="西瓜"><label for="watermelon">西瓜</label>
<input type="checkbox" id="peach" value="蜜桃"><label for="peach">蜜桃</label>
</p>
<input type="button" id="btn1" value="提示">
</body>
</html>