I want when i click select all then all checkbox will selected and when I click again all checkbox will deselect.
but when I click it nothing happen.
my code
$(document).ready(function() {
$("#check-all").click(function() {
var check = $(this).attr('checked');
if (check == "checked") {
$("#deleteid").attr('checked', 'checked');
} else
$("#deleteid").removeAttr('checked');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="sort_select_delete_form" method="get">
<div class="btn-group">
<a href="#check-all" class="btn btn-primary" id="check-all">Select All</a>
<input type="submit" class="btn btn-danger" value="Delete Selected">
</div>
<input class="form-check-input" type="checkbox" value="1000000001" id="deleteid[]" name="deleteid[]">select1
<input class="form-check-input" type="checkbox" value="1000000002" id="deleteid[]" name="deleteid[]">select2
<input class="form-check-input" type="checkbox" value="1000000003" id="deleteid[]" name="deleteid[]">select3
<input class="form-check-input" type="checkbox" value="1000000004" id="deleteid[]" name="deleteid[]">select4
<input class="form-check-input" type="checkbox" value="1000000005" id="deleteid[]" name="deleteid[]">select5
</form>
Aucun commentaire:
Enregistrer un commentaire