Changing color on <a> inside <div> when radio button is checked?

风格不统一 提交于 2019-12-13 04:46:34

问题


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.



来源:https://stackoverflow.com/questions/11160213/changing-color-on-a-inside-div-when-radio-button-is-checked

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!