jquery获取input的checked属性

1.经常需要判断某个按钮是否被选中。

2.基于jquery。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>checked</title>
</head>
<body>
<input id="box" type="checkbox" checked>

<script src="./jquery-3.1.1.min.js"></script>
<script>
    $("#box").on("click",function(){
//        console.log($("#box").attr("checked"))
        if($(this).is(":checked")){
            console.log("yes")
        }
    })
    
  
</script>
</body>
</html>
原文地址:https://www.cnblogs.com/chengyunshen/p/7277242.html