Changing color on inside
when radio butt

2019-09-04 06:43发布

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条回答
Anthone
2楼-- · 2019-09-04 07:18

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.

查看更多
登录 后发表回答