Your issue was not clearly specified, but the following code may address your needs. Take note of using jQuery's .prop() instead of .attr()
$(document).ready(function () {
// Select all checkboxes and uncheck selectall if any are not checked
var checkall = $('#checkall');
var boxes = $('input[type="checkbox"]').not(checkall);
checkall.click(function () {
var checked = $(this).is(':checked');
boxes.prop('checked', checked);
});
boxes.change(function () {
checkall[0].checked = this.checked && boxes.filter(':checked').length === boxes.length;
});
// Show the value of selected checkbox in the div with id "checked"
$('input:checkbox').click(function () {
var $checked = $('#checked');
$checked.html('');
$('input:checkbox').each(function (index) {
if ($(this).is(':checked')) {
$checked.append('<div>' + $(this).attr('id') + '</div>');
}
});
});
});