I'm creating checkboxes from the DB. I have another one that defines whether all the others are marked or not. When I run the first time it works fine, but the second one does not.
HTML
<div class="row smart-form">
<section class="col col-3">
<div class="checkbox">
<label>
<input type="checkbox" name="selectAll" id="check0" class="checkbox style-0 checkDoc">
<span>Marcar/Desmarcar todos</span>
</label>
</div>
</section>
</div>
<div class="row smart-form">
@for(dt <- docTipo) {
<section class="col col-3">
<div class="checkbox">
<label>
<input type="checkbox" name="docTipo" id="[email protected]" class="checkbox style-0">
<span>@dt.descricao</span>
</label>
</div>
</section>
}
</div>
JQUERY
$(document).on('change','.checkDoc', function() {
if(this.checked) {
$("input[name=docTipo]").attr("checked", true);
$("input[name=docTipo]").attr("disabled", true);
} else {
$("input[name=docTipo]").attr("checked", false);
$("input[name=docTipo]").attr("disabled", false);
}
});
When the first click on the control checkbox all the others are selected and disabled, the second click is all de-selected and enabled, the third one is only disabled but not marked. I already inspected the element, and the checked one is added in each one but in the browser the visa does not appear: s
Inspect Element
Any suggestions?