I have a table with checkbox at the beginning of a row. I have a button that is hidden. If I check one checkbox the button shows. If I uncheck it, the button hides. It works fine. My problem is, if I have all checkboxes "checked" and uncheck one checkbox from those checked ones, the button hides. It should not hide because there are still checkboxes checked. How am I going to fix this?
Here is my code
Script:
$('table').on('change', ':checkbox', function(){
if (!this.checked)
{
$('#delete').hide();
}
else
{
$('#delete').show();
}
});
Html:
<table class="table table-hover table-condensed" style = "font-size: 13px;">
<tr>
<th><input type ="checkbox" id = "chkall"></th>
<th>Type</th>
<th>Brand</th>
<th>Description</th>
<th>Serial No</th>
<th>Asset No</th>
<th>Date of Purchased</th>
<th>Warranty Expiration</th>
<th>Status</th>
</tr>
<tr>
<td><input type ="checkbox"></td>
<td>Keyboard</td>
<td>HP</td>
<td>One time use keyboard</td>
<td>123456</td>
<td>789456</td>
<td>July 5, 2019</td>
<td>August 6, 2015</td>
<td>Available</td>
</tr>
<tr>
<td><input type ="checkbox"></td>
<td>Keyboard</td>
<td>HP</td>
<td>One time use keyboard</td>
<td>123456</td>
<td>789456</td>
<td>July 5, 2019</td>
<td>August 6, 2015</td>
<td>Available</td>
</tr>
<tr>
<td><input type ="checkbox"></td>
<td>Keyboard</td>
<td>HP</td>
<td>One time use keyboard</td>
<td>123456</td>
<td>789456</td>
<td>July 5, 2019</td>
<td>August 6, 2015</td>
<td>Available</td>
</tr>
<tr>
<td><input type ="checkbox"></td>
<td>Keyboard</td>
<td>HP</td>
<td>One time use keyboard</td>
<td>123456</td>
<td>789456</td>
<td>July 5, 2019</td>
<td>August 6, 2015</td>
<td>Available</td>
</tr>
<tr>
<td><input type ="checkbox"></td>
<td>Keyboard</td>
<td>HP</td>
<td>One time use keyboard</td>
<td>123456</td>
<td>789456</td>
<td>July 5, 2019</td>
<td>August 6, 2015</td>
<td>Available</td>
</tr>
</table>
Aucun commentaire:
Enregistrer un commentaire