I want to alternate the background-color of rows.
I'm trying to select <td>
elements of even rows that are not hidden.
I'm trying the following:
$(".results-table tr:not(.hidden-row):even")
.children("td")
.css("background-color", "#f1f5f9");
but it's not working. I guess I can't use 2 selectors the way I am. Can someone suggest how to do this correctly?
You can use filter() for that purpose:
$(".results-table tr:not(.hidden-row)").filter(":even")
.children("td").css("background-color", "#f1f5f9");
This will also increase performance, since :even is a jQuery extension, not a native CSS selector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With