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