0
votes

I have classic bootstrap html table with .table-striped class - it means zebra-striping (every even row has different color than odd).

On same site is filter witch show or hide rows in this table (it depends on filled inputs)

So from table wtih rows like this:

enter image description here

I get rows like this:

enter image description here

How I can resolve this problem? Is there some CSS way to do it? I can see solution with jquery iteration each row and change background-color but it seems to me as dirty solution.

EDIT:

CSS in bootstrap says:

.table-striped>tbody>tr:nth-of-type(odd) {
    background-color: #f9f9f9;
}

I hiding rows like this:

var tableRows = $('#myTable');
    tableRows.each(function() {
        if(condition) {
            $(this).hide();
            ...
1
is there any hidden rows in between? - programtreasures
yes... they are hidden - Lajdák Marek

1 Answers

1
votes

Try by adding below script to manage hidden rows,

$("tr:not(.hidden)").each(function (index) {
    $(this).toggleClass("stripe", !!(index & 1));
});

Add this script on load and when ever you are hide/show the row