mardi 29 mars 2016

Toggle checkboxes with jQuery

I have a form with a random number of checkboxes. I' trying to toggle them on/off via jquery when the top one is checked/un-checked BUT skip any checkboxes that are disabled. The first checkbox has an id of "select_all" and the jquery is shown below. This works fine the FIRST time, but all subsequent attempts fail. I don't see any errors in Chrome's console. Any ideas? I don't care if I use this code or something else.

<script>
    $('#select_all').click(function() {
        var c = this.checked;
        if(c == true){
            $('input:checkbox:not(:disabled)').attr('checked','checked');
        } else {
            $('input:checkbox:not(:disabled)').removeAttr('checked');
        }
    });
</script>




Aucun commentaire:

Enregistrer un commentaire