> Please consider the code below, supposed to check all child checkboxes
> wjen a parent checkbox has been checked.
>
> //parentCheckbox and childCheckboxes are two variables set earlier.
> //Here are typical values they produce once alert()
> //I reproduce the exact string outputed when alert() :
> //childCheckboxes -> child-city-id-120
> //parentCheckbox-> #city-id-120
>
> $('INPUT[class=childCheckboxes]').attr('checked', $(parentCheckbox).is
> (':checked'));
>
> Do you spot the problem?
You want to add or remove the 'checked' attribute, not set its value
to a boolean. Try something like this:
var $inputs = $('input.childCheckboxes');
if ($(parentCheckbox).is(':checked'))
$inputs.attr('checked','checked');
else
$inputs.removeAttr('checked');