$(document).ready(function () { $(function () { $("[id*=chkAll]").bind("click", function () { if ($(this).is(":checked")) { $("[id*=chklstSezioni] input").attr("checked", "checked"); } else { $("[id*=chklstSezioni] input").removeAttr("checked"); } }); $("[id*=chklstSezioni] input").bind("click", function () { if ($("[id*=chklstSezioni] input:checked").length == $("[id*=chklstSezioni] input").length) { $("[id*=chkAll]").attr("checked", "checked"); } else { $("[id*=chkAll]").removeAttr("checked"); } }); }); });