Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery checkbox: select all/none except one
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload