jQuery判断checkbox是否选中的3种方法
项目中经常会判断表单复选框的选中状态,总结以下3种常用的方法:
方法一(推荐):
if($("#checkbox").is(":checked")) {
// do something
}方法二:
if ($("#checkbox").attr("checked")) {
// do something
}方法三:
if ($("#checkbox").get(0).checked) {
// do something
}

![[反调试]审查元素清空页面或重定向](https://www.toyean.com/zb_users/upload/2025/08/202508211755747106292974.png)