Change table row color if checked using CSS3 selectors?

Is there a way to change the color of a row in a table when a checkbox in a row is checked using only CSS selectors?

I have the following, but it changes the color of the checkbox, not the table cell:

.table_class tr td.column0 input[type="checkbox"]:checked { background-color:#f00; }
+3
source share
2 answers

Can you use some js? This will act as a flag without using the flag. Demo

$("table tr").click(function() {
   $("table tr").css("background", "red"); //reset to original color
   $(this).css("background", "blue"); //apply the new color
});
+3
source

AFAIK, which is not possible with pure CSS to work out both conditions of the checkbox. This will not work in IE <9. You will have to resort to javascript for this.

+2
source

Source: https://habr.com/ru/post/1772525/


All Articles