Reputation: 12064
div.test:hover #sendBtn{
color:red;
}
This works fine is sendBtn is INSIDE the div.test element
But how to achieve this (pure CSS) when it is outside ? ex:
<button id="sendBtn">hello</button>
<div class='test'>div here</div>
Upvotes: 1
Views: 272
Reputation: 33218
There is no selector for previous element in css but you can change the order of the elements and use adjacent sibling selector:
html
<div class='test'>div here</div>
<button id="sendBtn">hello</button>
css
div.test:hover + #sendBtn {
color:red;
}
Upvotes: 2