When utilizing bootstrap, I want to ensure that the background color remains on the odd rows, even when hiding a specific row.
Desired Outcome: The grey background should always be present on the 1st and 3rd rows, regardless of whether the input is checked or not.
This is the code snippet:
function toggleRow() {
if ($('#product-toggle').prop("checked")) {
if ($('tr:has(td.status-locked)') || $('tr:has(td.product-status-whitelabel.status-locked)')) {
$('tr:has(td.status-locked)').hide();
}
} else {
$('tr:has(td.status-locked)').show();
}
}
toggleRow();
$('#product-toggle').on('change', toggleRow);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap.min.css">
<h4>If input checked hide tr with certain class(status-locked), also keep the background image on the odd tr's</h4>
<pre>
<input type="checkbox" id="product-toggle"> <label for="product-toggle" >click me!</label>
</pre>
<table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
<th>Header 4</th>
</tr>
<tr>
<td>Entry First Line 1</td>
<td>Entry First Line 2</td>
<td>Entry First Line 3</td>
<td class="status-locked">Entry First Line 4</td>
</tr>
<tr>
<td>Entry Line 1</td>
<td>Entry Line 2</td>
<td>Entry Line 3</td>
<td>Entry Line 4</td>
</tr>
<tr>
<td>Entry Last Line 1</td>
<td>Entry Last Line 2</td>
<td>Entry Last Line 3</td>
<td>Entry Last Line 4</td>
</tr>
</table>