title: Check the parent checkbox with jQuery
body: <p>Basically I am trying to write a js func that if I check a child checkbox the parent checkbox also checks, if not already checked. I am using jquery here is my html: </p>
  
  <pre><code>      &lt;ul id="ulParent" style="margin: 0; padding: 0; list-style: none;"&gt;
              &lt;li style="margin: 0 0 5px 0;"&gt;
                  &lt;input type="checkbox" checked="checked" class="liParent" id="p1" /&gt;Parent1
                  &lt;ul id="ulParent" style="margin: 0; padding: 0; list-style: none;"&gt;
                      &lt;li&gt;
                          &lt;input type="checkbox" checked="checked" class="liChild" id="c1" onclick="checkParent(this);" /&gt;Child1
                      &lt;/li&gt;
                      &lt;li&gt;
                          &lt;input type="checkbox" checked="checked" class="liChild" id="c2" onclick="checkParent(this);"/&gt;Child2
                      &lt;/li&gt;
                      &lt;li&gt;
                          &lt;input type="checkbox" checked="checked" class="liChild" id="c3" onclick="checkParent(this);"/&gt;Child3
                      &lt;/li&gt;
                      &lt;li&gt;
                          &lt;input type="checkbox" checked="checked" class="liChild" id="c4" onclick="checkParent(this);"/&gt;Child4
                      &lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/li&gt;
  
              &lt;li style="margin: 0 0 5px 0;"&gt;
                  &lt;input type="checkbox" checked="checked" class="liParent" id="p2" /&gt;Parent2
                  &lt;ul id="ulParent" style="margin: 0; padding: 0; list-style: none;"&gt;
                      &lt;li&gt;
                          &lt;input type="checkbox" checked="checked" class="liChild" id="c1" onclick="checkParent(this);" /&gt;Child1
                      &lt;/li&gt;
                      &lt;li&gt;
                          &lt;input type="checkbox" checked="checked" class="liChild" id="c2" onclick="checkParent(this);"/&gt;Child2
                      &lt;/li&gt;
                      &lt;li&gt;
                          &lt;input type="checkbox" checked="checked" class="liChild" id="c3" onclick="checkParent(this);"/&gt;Child3
                      &lt;/li&gt;
                      &lt;li&gt;
                          &lt;input type="checkbox" checked="checked" class="liChild" id="c4" onclick="checkParent(this);"/&gt;Child4
                      &lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>JS Func</p>
  
  <pre><code>function checkParent(child){
  
  if (child != null) {
  
      // if child is checked we need to check the parent category       
      if (child.checked) {
      // get the parent checkbox and check it if not check....need help here....
             $(child).parent().parent().parent()......
  
         }
      }
   }
  </code></pre>