简体   繁体   中英

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. 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.

您在jQuery选择器的末尾缺少一个]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM