1
I have an array of the Laravel that renders checkboxes:
@foreach($images as $img)
<div class="col-md-3">
<img src="{{url('gallery_images')}}/{{ $img->image }}" class="img-thumbnail" alt="">
<label class="check-box">
<input type="checkbox" name="excluir_todos[]" id="check-{{ $img->id }}" value="{{ $img->id }}"/>
<span class="checkmark"></span>
</label>
</div>
<script src="{{ url('templates/admin/plugins/jquery/jquery.min.js') }}"></script>
<script>
$('#check-{{ $img->id }}').click(function() {
console.log($('#check-{{ $img->id }}').is(':checked'));
if($('#check-{{ $img->id }}').is(':checked')){
$('#btn-delete').removeClass('hide')
}else{
$('#btn-delete').addClass('hide')
}
});
</script>
@endforeach
I want to show a button only if at least one of the checkbox is selected. The way it is above, when I select several checkboxes, it shows the button, but when I uncheck only one option it hides the button. I want it to hide only when all checkboxes have been cleared. Can anyone help me?
Possible duplicate of Show button when checking checkbox
– Leandro Angelo