Resolved: dynamically change the colour of a table-hover in bootstrap based on a cell value

In this post, we will see how to resolve dynamically change the colour of a table-hover in bootstrap based on a cell value

Question:

I have a simple table using table-hover
Fiddle
I’ve found ways to change the default hover colour, and I can change the table row or cell background with the usual conditional formatting but that’s not what I’m looking for.
e.g
I’m trying to format the hover colour based on the value in the ‘status’ column with red for ‘late’ and green for ‘early’ etc. so that I can maintain the same look and feel of the table.

Best Answer:

You can simply add class to your tr indicating the color you want to see on hover


If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com