<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>使用 click 点击事件切换checkbox的选中状态</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<div>
<label for="checkbox">
<input type="checkbox" name="money" id="checkbox">
选项
</label>
</div>
<button id="chk-btn">选中</button>
<button id="cancel-btn">取消选中</button>
<script>
$(function (){
$("#chk-btn").click(function (){
toogle(true);
});
$("#cancel-btn").click(function (){
toogle(false);
});
function toogle(checked){
var value = $("#checkbox").prop("checked");
if (checked != value) {
$("#checkbox").click();
}
}
});
</script>
</body>
</html>