[英]Why won't this event listener work?
$('input[type=checkbox]').unbind().click(function(e){
$(this).attr('checked', true)
return false;
});
I NEED to return false because I have an event on its parent and I don't want to trigger that. 我需要返回false,因为我在其父项上有一个事件,并且我不想触发它。 It just WON'T check that checkbox.
它只是不会选中该复选框。
$('input[type=checkbox]').unbind().click(function(e){
e.stopPropagation();
});
Edit: I'm not sure what you need .unbind()
for, but you should beware that that is canceling any other events you've put on those checkboxes. 编辑:我不确定您需要
.unbind()
用于什么,但是您应该注意,这将取消您放置在这些复选框上的任何其他事件。
您在jQuery选择器的末尾缺少一个]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.