title: jQuery checkbox: select all/none except one
body: <p>I have a checkbox select all issue. I have multiple checkbox that can be triggered by a master one.</p>
  
  <p>If the master one is check then you can select any checkbox (which this works). Now my problem is when i check "none" all of them are gone even the master</p>
  
  <p>What I need is not to unchecked the master. I can have as many as checkbox as I want.</p>
  
  <p>Is there a solution to do this without putting an ID on each or automatically uncheck all checkbox and not the master one?</p>
  
  <p>here is my code:</p>
  
  <pre><code> &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
    $(document).ready(function() {
    $('#checkAll').click(function() {
      if(!$('#master').is(':checked')) {  return;
      } $('input[type="checkbox"]').attr('checked', true);
    });
  
    $('#checkNone').click(function() {
      $('input[type="checkbox"]').attr('checked', false); });
  
    $('#master').click(function() { if($('#master').is(':checked')) {
          return; } $('input[type="checkbox"]').attr('checked', false);
    });
    $('input[type="checkbox"]').click(function() {
      if(!$('#master').is(':checked')) { $(this).attr('checked', false);
      }
    });
    });
  
    &lt;/script&gt;
    &lt;/head&gt;
  
    &lt;input type="checkbox" value="master" id="master"&gt;master
    &lt;span id="checkAll"&gt;All&lt;/span&gt;
    &lt;span id="checkNone"&gt;None&lt;/span&gt;
  
    &lt;input type="checkbox" value="1" id="c1"&gt;1
    &lt;input type="checkbox" value="2" id="c2"&gt;2
    &lt;input type="checkbox" value="3" id="c3"&gt;3
    &lt;input type="checkbox" value="4" id="c4"&gt;4
    &lt;input type="checkbox" value="5" id="c5"&gt;5
  </code></pre>