Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

Check-Uncheck all child checkboxes if parent checkbox checked or unchecked

In a table, with rows, every row has a check box, and there is a main check box at the thead.

Use following code example if you want to check and uncheck child check box when parent check box checked or unchecked(on change)

Code example

$("#chkParent").change(function () {
            if ($(this).prop('checked')) {
                $('#c4uSampleTable tbody input:checkbox ').each(function () {
                    $(this).prop('checked', true);
                });
            } else {
                $('#c4uSampleTable tbody input:checkbox').each(function () {
                    $(this).prop('checked', false);
                });
            }
        });


Invalid entry,please enter valid data.

Loading