Select All checkboxes using jQuery

前端 未结 15 1615
渐次进展
渐次进展 2020-12-05 06:26

I have the following html code:

    
    

15条回答
  •  情歌与酒
    2020-12-05 07:13

    $(document).ready(function() {
        $('#ckbCheckAll').click(function() {
            $('.checkBoxClass').each(function() {
                $(this).attr('checked',!$(this).attr('checked'));
            });
        });
    });
    

    OR

    $(function () {
        $('#ckbCheckAll').toggle(
            function() {
                $('.checkBoxClass').prop('checked', true);
            },
            function() {
                $('.checkBoxClass').prop('checked', false);
            }
        );
    });
    

提交回复
热议问题