I have the following
<ul>
<li>Main
<ul>
<li><input type="checkbox" onclick="$.SelectChildren(this);" /> parent 1
<ul>
<li><input type="checkbox" onclick="$.SelectChildren(this);" />sub 1</li>
<li><input type="checkbox" onclick="$.SelectChildren(this);" />sub 2
<ul>
<li><input type="checkbox" onclick="$.SelectChildren(this);" />sub sub 2</li>
<li><input type="checkbox" onclick="$.SelectChildren(this);" />sub sub 3</li>
</ul>
</li>
</ul>
</li>
<li><input type="checkbox" onclick="$.SelectChildren(this);" />parent 2</li>
</ul>
</li>
</ul>
Now for my JQuery function:
(function ($) {
$.SelectChildren = function (element) {
if ($(element).is(':checked')) {
$(element).parent().find(':checkbox').attr('checked', true);
}
else {
$(element).parent().find(':checkbox').attr('checked', false);
}
}
})(jQuery);
how would I unselect ONLY (all)parent checkboxes when un-checking a child
for example: when clicked "sub sub 2" checkbox -> it should uncheck "sub 2" and "parent 1" checkboxes as well.
thanks