I am trying to reapply table striping from Bootstrap after hiding table rows with Jquery. A checkbox is used to hide rows in which a cell contains “No”. When I use the hide() function, the striping gets applied correctly after hiding rows, but if I use the fadeOut() function, the striping does not get applied correctly
Jquery hiding table rows hide() vs fadeOut() stripe table
$(document).ready(function () { $('#customSwitch1').change(function () { if (!this.checked) $('#indexTable tr td:contains(No)').parent().fadeIn('fast'); else $('#indexTable tr td:contains(No)').parent().hide(); $("#indexTable tr:visible").each(function (index) { $(this).css("background-color", !!(index & 1) ? "rgba(0,0,0,0)" : "rgba(0,0,0,0.05)"); }); }); $('#customSwitch1').change(); });
If I replace hide() with a fadeout, the striping does not get applied correctly (or put a duration into the hide function)