title: jquery checkall button and uncheckall button to select other checkbox
body: <p>please anyone tell me how to set check all and uncheck all when i check single checkbox one by one after all check , the above checkall and uncheck all is checked that is why he is checked. here is the Code im currently using:
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function(){
  
  $('.checkall').click(function(){
          $('input:checkbox').prop('checked',true);
          $('.uncheckall').prop('checked',false);
          console.log(checkedValues);
      });
      $('.uncheckall').click(function(){
           $('input:checkbox').prop('checked',false);
           $(this).prop('checked',true);
      });
      $('.single').on('click',function(){
          if($('.single:checked').length == $('.single').length){
              $('.checkall').prop('checked',true);
              $('.uncheckall').prop('checked',true);
          }else{
              $('.checkall').prop('checked',false);
              $('.uncheckall').prop('checked',false);
          }
      });
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"&gt;&lt;/script&gt;
  )&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;jquery checked&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;label&gt;checked all&lt;/label&gt;
  &lt;input type="checkbox" name="check123" class="checkall"&gt;
  &lt;label&gt;unchecked all&lt;/label&gt;
  &lt;input type="checkbox" name="check123" class="uncheckall"&gt;
  &lt;div&gt;
  &lt;p&gt;select&lt;/p&gt;
    &lt;input type="checkbox" name="check123" class="single"&gt;
    &lt;input type="checkbox" name="check123" class="single"&gt;
    &lt;input type="checkbox" name="check123" class="single"&gt;
    &lt;input type="checkbox" name="check123" class="single"&gt;
    &lt;input type="checkbox" name="check123" class="single"&gt;
    &lt;input type="checkbox" name="check123" class="single"&gt;
  
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>