I have two divs:
<div>
<a id="changecolor">Change Color</a>
</div>
<div id="tobechanged">
Change My Color
</div>
I have two questions:
- How can I use CSS only to make it so that the background color of
#tobechanged
changes when I hover on "#changecolor"? - Is there a way, using only
CSS3
, such that clicking on "changecolor" would trigger the CSS color change instead of an on hover?
The following is what I tried:
#changecolor:hover + #tobechanged {
background:yellow;
}
This works only when I have something like this:
<div>
<a id="changecolor">Change Color</a>
<div id="tobechanged">
Change My Color
</div>
</div>
But I do not want to have "tobechanged" be a sibling or child of "changecolor".