See the following code:
$(document).ready(function() {
$('.checkbox-group .parents-checkbox .panel-title input').click(function () {
$(this).closest('.checkbox-group').find('input[type="checkbox"]').not(this).prop('checked', this.checked).closest('label');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="panel panel-default item-box-roll checkbox-group">
<div class="panel-heading parents-checkbox">
<h3 class="panel-title">
<input type="checkbox" name="rolls[]" id="selecctall" value="2" checked=""> Items
</h3>
</div>
<div class="panel-body child-checkbox">
<input type="checkbox" class="checkbox1" name="rolls[]" value="20" checked=""> Items management<br>
<input type="checkbox" class="checkbox1" name="rolls[]" value="21" checked=""> Add item<br>
<input type="checkbox" class="checkbox1" name="rolls[]" value="22" checked=""> Edit items<br>
</div>
</div>
When i click on first checkbox therefore select all checkbox in child-checkbox div. I want to if selected each of checkbox in child-checkbox div then check first checkbox! How can I change the code?