在< a>上更改颜色内部< div>当单选按钮被选中? [英] Changing color on <a> inside <div> when radio button is checked?

查看:171
本文介绍了在< a>上更改颜色内部< div>当单选按钮被选中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

当第一个单选按钮被选中时,我在尝试更改< a> 标签上的属性时遇到一些麻烦。当我要更改< label> 属性时,它工作正常,但检查但不是< a>

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>

任何人都可以帮助我。

推荐答案

code> + 选择器意味着两个元素之间不能有任何其他元素。原因 + label 的工作原因是您的标签紧接在单选按钮之后。然而,标签位于单选按钮和 div 之间,因此#radio-

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.

您需要使用

#radio-one:checked + label + div a

更新了小提示

另请参阅此答案,说明 + selector工作。

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

这篇关于在&lt; a&gt;上更改颜色内部&lt; div&gt;当单选按钮被选中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆