举个例子
<body><input type="checkbox" id="box" checked>123
<script>
var box = document.getElementById('box')
if(box.checked) {
console.log('复选框被选中')
}
</script>
</body>
该案例复选框被选中,所以会出输出'复选框被选中'。checked属性存在会自动转换为bool值true,所以可以if语句做判断。
var len=$("input[type=checkbox]:checked()")if(len.length>0){
alert("有选中")
}else{
alert("没有选中")
}