How to uncheck a checkbox even if one among the list is unchecked?
<p>I am trying a check a checkbox (which checks all other checkboxes in the list and unchecks even if one among the list is unchecked. Now only the first I mean one checkbox checking all the remaining checkboxes in the list is happening but the vice versa I mean unchecking even if one among the list in unchecked is not working. How can i achieve that?</p>

<pre><code>&lt;label&gt;&lt;input type="checkbox" name="sample" class="selectall"/&gt; Select all&lt;/label&gt;

&lt;div id="checkboxlist"&gt;
&lt;label&gt;&lt;input type="checkbox" name="sample"/&gt;checkbox1&lt;/label&gt;&lt;br/&gt;
&lt;label&gt;&lt;input type="checkbox" name="sample"/&gt;checkbox2&lt;/label&gt;&lt;br /&gt;
&lt;label&gt;&lt;input type="checkbox" name="sample"/&gt;checkbox3&lt;/label&gt;&lt;br /&gt;
&lt;label&gt;&lt;input type="checkbox" name="sample"/&gt;checkbox4&lt;/label&gt;&lt;br /&gt;

 &lt;/div&gt; 
</code></pre>

<p><a href="https://jsfiddle.net/Goutham_Pratapa/1tn3treb/" rel="nofollow">Fiddle.</a></p>