<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CheckBox Prop 和 attr 的区别</title>
</head>
<body>
<input type="text" />
<label>选中 <input type="checkbox" checked /></label>
<script src="./jquery-3.4.1.min.js"></script>
<script src="./jquery-migrate-1.2.1.js"></script>
<script>
$("input[type=checkbox]").bind("change", function () {
console.log($(this).attr("checked")); // 返回 undefined 或 checked
console.log($(this).prop("checked")); // 返回 true 或 false
});
</script>
</body>
</html>