lundi 30 octobre 2017

jquery setting checkbox state after preventing default action

I have a checkbox that needs to change state, but without invoking parent's click event. So, I created this:

    $("#divTabBody@(Model.TabNumber) tr input[type='checkbox']").on('click', function(e) { 
    e.preventDefault();
    e.stopPropagation();
    if($(this).is(':checked'))
        $(this).prop('checked', false);
    else
        $(this).prop('checked', true);
});

Parent's click is not execcuting, so that's good, but the checkbox is not changing state. Why?




Aucun commentaire:

Enregistrer un commentaire