I'm trying to use javascript to hide all rows that don't match AB, so if it's in column BB, BA or AA, I'm trying to hide these columns. All my attempts failed
My attempt
<div class="wrapper">
<div class="data-table">
<table class="table table-bordered text-center table-dark" id="data-table">
<tr>
<td>a</td>
<td>b</td>
</tr>
<tr>
<td>b</td>
<td>a</td>
</tr>
<tr>
<td>b</td>
<td>b</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>b</td>
<td>b</td>
</tr>
<tr>
<td>a</td>
<td>b</td>
</tr>
</table>
</div>
<div class="btn-group d-flex justify-content-between">
<button id="btn-only-ab" class="btn btn-warning" type="button">a & b</button>
</div>
</div>
And my javascript
$(document).ready(function () {
$("#btn-only-ab").click(function () {
$("tr").each(function (column, td) {
var cellText = $(this).html();
if (cellText === ["b", "b"] || ["b", "a"] || ["a", "a"]) $(td).toggle();
console.log(cellText);
});
});
});