Changing color on inside
when radio butt

2019-09-04 06:50发布

问题:

http://jsfiddle.net/anvhw/1/

I'm having some trouble trying to change a property on the <a> tag when the first radio button is checked. It works fine when I want to change a <label> property when one is checked but not with the <a>

Can anyone help me out?

回答1:

The + selector means there must not be any other elements coming between the two elements. The reason + label works is because your label comes immediately after your radio button. However, that label is standing between your radio button and the div, so #radio-one:checked + div won't work.

You need to use

#radio-one:checked + label + div a

Updated fiddle

Also see this answer for an illustration on how the + selector works.