Posted By

knedle on 08/24/10


Tagged

jquery


Versions (?)

check / uncheck checkboxes in tree


 / Published in: jQuery
 

URL: http://jsfiddle.net/4QmNn/

logical action on tree with checkboxes

  1. $("ul input:checkbox").change(function(){
  2.  
  3. if ($(this).is(':checked')) {
  4. // children
  5. $(this).parent().find("input:checkbox").attr('checked', 'checked');
  6. }
  7. else {
  8. // children
  9. $(this).parent().find("input:checkbox").removeAttr('checked');
  10. // parents
  11. $(this).parents('li').each(function(){
  12. $(this).children('input:checkbox').removeAttr('checked');
  13. });
  14. }
  15. });

Report this snippet  

You need to login to post a comment.