jquery判断checkbox是否被选中

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="jquery-3.2.1.min.js"></script>
<script>
$(function(){
    $("input[type=checkbox]").change(function(e) {
        //alert(this.checked);
        if(this.checked)
        {
            alert('我被选中了');
        }else
        {
            alert('我没被选中');
        }
    });
});
</script>
</head>

<body>
<input type="checkbox" />
</body>
</html>

 

posted on 2017-11-07 22:55  ZQC  阅读(659)  评论(1编辑  收藏  举报