杨晨光:jquery的checkbox选中不选中触发事件
简延芮的回答:
<!--默认选中--><input type="checkbox" checked="checked" id="ck"> <script> $(function () { // 动态绑定默认状态 // $("#ck").attr("checked",true)//选中 // $("#ck").attr("checked",false)//未选中 //点击判断选中还是未选中 $("#ck").click(function () { if ($(this).is(":checked")) { alert("选中"); } else { alert("未选中"); } }) }); </script>
春风秋雨的回答:
<!--默认选中--><input type="checkbox" checked="checked" id="ck"> <script> $(function () { // 动态绑定默认状态 // $("#ck").attr("checked",true)//选中 // $("#ck").attr("checked",false)//未选中 //点击判断选中还是未选中 $("#ck").click(function () { if ($(this).is(":checked")) { alert("选中"); } else { alert("未选中"); } }) }); </script>