checked
is a property, you should use prop
method, when a boolean attribute like disabled
or checked
is set to an element, the value is mapped to the relevant DOM property of the element(browser do this), as of jQuery 1.6
for modifying properties, prop
method should be used instead of attr
.
So you code should looks like this
currentMultiSelect.next('.multiSelectOptions').find('INPUT.selectAll').click(function () {
if ($(this).is(':checked'))
$(this).parent().parent().find('INPUT:checkbox').prop('checked', true).parent().addClass('checked');
else
$(this).parent().parent().find('INPUT:checkbox').prop('checked', false).parent().removeClass('checked');
});
Better if you use .is(":checked")
for checking whether the checkbox is checked or not. But use prop
to set the checked property of checkbox
.