Consider the following HTML structure:
<input type=radio name=picker value=foo> <input type=radio name=picker value=bar> etc
<ul>
<li class=foo>Foo #1</li>
<li class=bar>Bar #1</li>
<li class=foo>Foo #2</li>
<li class=bar>Bar #2</li>
</ul>
I want to style those list items which match the currently-selected radio button. This works if all the possible radio button values are hard-coded:
input:checked[value=foo] ~ ul li[class~=foo] {
background: blue;
color: white;
}
input:checked[value=bar] ~ ul li[class~=bar] {
background: blue;
color: white;
}
Is there any way to say "input:checked" and then "li[class~=[the value of the currently-selected input]]" ? Assume that the radio buttons and list items are all dynamically generated.
If all else fails, I can dynamically generate the CSS too, but that seems unideal.