I have a HTML which looks like this:
<p>
<a id="foo" href="#bar">FOO</a><br/>
<a id="bar" href="#foo">BAR</a><br/>
</p>
Now I want to highlight "BAR" when "FOO" is hovered, and vice versa. Is there a way to accomplish this in CSS3, or do I need jQuery?
I have tried this:
a#foo:hover ~ a[href="#foo"] {
color:red;
background-color:blue;
}
a#bar:hover ~ a[href="#bar"] {
color:red;
background-color:blue;
}
But the ~ operator only works forward, so it will work fine for the first link, but not for the second one.
See also here: http://jsfiddle.net/pw4q60Lk/