'How to change the background and text color for even rows in table view JavaFX when the row is selected

In JavaFx every row is by default white and on click action the background is blue and text color white. I changed the background of every odd row with css like this:

.table-row-cell:odd{
    -fx-background-color: #b3b300;
}

but I do not know how can i change the background and the text color when a row is selected Only for odd rows. For even rows i do not want to change anything.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source