I have a laravel array 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 checkboxes is selected. From the way it is above, when I select multiple checkboxes, it shows the button, but when I uncheck only one option it hides the button. I want it to hide only when all the checkboxes have been cleared. Can anyone help me?