当前位置: > 热文

杨晨光:jquery的checkbox选中不选中触发事件

时间:2022-04-19 12:14:46 热文 我要投稿

简延芮的回答:

                <script>                    $(function () {            // 动态绑定默认状态            //  $("#ck").attr("checked",true)//选中            // $("#ck").attr("checked",false)//未选中            //点击判断选中还是未选中                        $("#ck").click(function () {                            if ($(this).is(":checked")) {                                alert("选中");                            } else {                                alert("未选中");                            }                        })                    });                </script>

春风秋雨的回答: