<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul class="list-group list-group-flush">
<li class="list-group-item">
<label class="container-box">green
<input type="checkbox" class="name" name="name" value="green" />
<span class="checkmark"></span>
</label>
</li>
<li class="list-group-item">
<label class="container-box">yellow
<input type="checkbox" class="name" name="name" value="yellow" />
<span class="checkmark"></span>
</label>
</li>
<li class="list-group-item">
<label class="container-box">red
<input type="checkbox" class="name" name="name" value="red" />
<span class="checkmark"></span>
</label>
</li>
</ul>
<ul class="list-group list-group-flush">
<li class="list-group-item">
<label class="container-box">apple
<input type="checkbox" class="name" name="name" value="apple" />
<span class="checkmark"></span>
</label>
</li>
<li class="list-group-item">
<label class="container-box">orange
<input type="checkbox" class="name" name="name" value="orange" />
<span class="checkmark"></span>
</label>
</li>
<li class="list-group-item">
<label class="container-box">mandarin
<input type="checkbox" class="name" name="name" value="mandarin" />
<span class="checkmark"></span>
</label>
</li>
</ul>
<table>
<thead>
<th>Color</th>
<th>Fruit</th>
</thead>
<tbody id='myTable'>
<tr>
<td>green</td>
<td>apple</td>
</tr>
<tr>
<td>yellow</td>
<td>orange</td>
</tr>
<tr>
<td>red</td>
<td>mandarin</td>
</tr>
</tbody>
</table>
$(document).ready(function(){
$(".name").on("click", function() {
name_list = []
$("#myTable tr").hide()
var flag = 1
$("input:checkbox[name=name]:checked").each(function(){
flag = 0;
var value = $.trim($(this).val().toLowerCase());
$("#myTable tr").filter(function() {
if($.trim($(this).text().toLowerCase().indexOf(value)) > -1)
$(this).show()
});
});
if(flag == 1)
$("#myTable tr").show()
});
});
const columnIndex = {
color: 0,
fruit: 1,
};
function filter() {
const filters = Object.entries(Array
.from(document.querySelectorAll('.list-group :checked'))
.reduce((acc, n) => ((acc[n.name] ??= []).push(n.value), acc), {})
);
document.querySelectorAll('table tbody tr').forEach(n => {
n.style.display = filters.some(([ k, v ]) => !v.includes(n.cells[columnIndex[k]].innerText))
? 'none'
: 'block';
});
}
document.querySelectorAll('.list-group').forEach(n => n.addEventListener('change', filter));