/ Published in: jQuery
logical action on tree with checkboxes
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$("ul input:checkbox").change(function(){ if ($(this).is(':checked')) { // children $(this).parent().find("input:checkbox").attr('checked', 'checked'); } else { // children $(this).parent().find("input:checkbox").removeAttr('checked'); // parents $(this).parents('li').each(function(){ $(this).children('input:checkbox').removeAttr('checked'); }); } });
URL: http://jsfiddle.net/4QmNn/