$("#checkAllSelectedOrganization").live("click", function() { $('input[name="selected_org"]').attr("checked",this.checked);});var $selected_organization = $("input[name='selected_org']");$selected_organization.live("click", function(){ $("#checkAllSelectedOrganization").attr("checked", $("input[name='selected_org']").length == $("input[name='selected_org']:checked").length ? true : false);});