I have this issue and can't figure out why my code isn't working.
I want to select all checkboxes when clicking on "Todas".
I made a fiddle with the code and it works there, but when running on my project it doesn't, even though no errors are displayed while inspecting.
The jQuery function is from another post :
$('#allstates').click(function() {
var c = this.checked;
$(':checkbox').prop('checked',c);
});
and html code snippet is:
<div class="hide" id="states">
<div class="control-group">
<label class="control-label">Seleccione</label>
<div class="controls">
<label class="checkbox span4">
<input type="checkbox" class="all" value="all" id="allstates" name="all"/>Todas
</label>
<label class="checkbox span4">
<input type="checkbox" value="Caba" id="" name="st[]"/>Ciudad Autónoma de Buenos Aires
</label>
<label class="checkbox span4">
<input type="checkbox" value="Buenos Aires" id="" name="st[]"/> Buenos Aires
</label>
<label class="checkbox span4">
<input type="checkbox" value="Catamarca" id="" name="st[]"/> Catamarca
</label>
<label class="checkbox span4">
<input type="checkbox" value="Chaco" id="" name="st[]"/> Chaco
</label>
</div>
</div>
</div>
Am I missing something?
EDIT
Found out by inspecting that the template I use adds these lines to the checkboxes and that is why this doesn't work on my code, but it does on fiddle.
Here is a snippet:
<label class="checkbox span4">
<div class="checker">
<span><input type="checkbox" value="Buenos Aires" id="" name="st[]">
</span>
</div> Buenos Aires
</label>
So now I'm still struggling to check and uncheck the elements...