title: jquery check checkboxes within an element only
body: <p>I have these audience groups with audiences hidden under it. When a user clicks on the audience group name, the hidden audiences will appear. now, what i want to do is when a user clicks on the audience group checkbox, only the audience checkboxes under it will be checked also. </p>
  
  <p>currently i have the following, but with a little bug, when i clicked on an audience group checkbox, all the audience checkbox, even those not under is also checked. i want only those audience under that audience group will be checked.</p>
  
  <p>you can see more of my code here: <a href="http://jsfiddle.net/CVnTy/" rel="nofollow">http://jsfiddle.net/CVnTy/</a></p>
  
  <p>i have this example html:</p>
  
  <pre><code>&lt;div class='audience-group'&gt;
      &lt;input type='checkbox' class='audience-group-checkbox' value='9' /&gt;
      &lt;div class='audience-group-name'&gt;
          JGG Enterprises
      &lt;/div&gt;
      &lt;div class='audience'&gt;
          &lt;input type='checkbox' class='audience-checkbox' value='7' /&gt;
          &lt;div class='audience-name'&gt;
              Mucho, George
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class='audience'&gt;
          &lt;input type='checkbox' class='audience-checkbox' value='9' /&gt;
          &lt;div class='audience-name'&gt;
              Bo, Jen
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class='audience'&gt;
          &lt;input type='checkbox' class='audience-checkbox' value='10' /&gt;
          &lt;div class='audience-name'&gt;
              Gin, Junto
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class='audience'&gt;
          &lt;input type='checkbox' class='audience-checkbox' value='12' /&gt;
          &lt;div class='audience-name'&gt;
              Molina, Greg
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class='audience'&gt;
          &lt;input type='checkbox' class='audience-checkbox' value='36' /&gt;
          &lt;div class='audience-name'&gt;
              Berkely, Dada
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div&gt;
      &lt;div class='audience-group'&gt;
          &lt;input type='checkbox' class='audience-group-checkbox' value='8' /&gt;
          &lt;div class='audience-group-name'&gt;
              GBA Inc.
          &lt;/div&gt;
          &lt;div class='audience'&gt;
              &lt;input type='checkbox' class='audience-checkbox' value='1' /&gt;
              &lt;div class='audience-name'&gt;
                  Kapate, Jones
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class='audience'&gt;
              &lt;input type='checkbox' class='audience-checkbox' value='2' /&gt;
              &lt;div class='audience-name'&gt;
                  Bingo, Gringo
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class='audience'&gt;
              &lt;input type='checkbox' class='audience-checkbox' value='4' /&gt;
              &lt;div class='audience-name'&gt;
                  Doe, John
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class='audience'&gt;
              &lt;input type='checkbox' class='audience-checkbox' value='8' /&gt;
              &lt;div class='audience-name'&gt;
                  Merio, Horhe
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class='audience'&gt;
              &lt;input type='checkbox' class='audience-checkbox' value='35' /&gt;
              &lt;div class='audience-name'&gt;
                  Dalisay, JM
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and my jquery code:</p>
  
  <pre><code>$('.audience-group-name').click(function() {
      if ($(this).nextUntil('.audience-group').length) {
          $(this).nextUntil('.audience-group').toggle();
      } else {
          alert('No audience under this group.');
      }
  });
  
  $('.audience-group-checkbox').each(function() {
      $(this).click(function() {
          $('.audience-checkbox').attr('checked', $(this).is(':checked'));
      });
  });
  </code></pre>
  
  <p>i'm kinda new to jquery, thanks for any help! :)</p>