Reputation: 3270
<div>highlight me</div><div><input /></div>
When the user puts their cursor in the input box and triggers :focus, I want to highlight the first div (apply a style to it).
non working example: https://codepen.io/samkeddy/pen/vJaqqv
Upvotes: 1
Views: 1442
Reputation: 767
Actually previous solution is absolute but
If you dont want to use the javascript here you can go with little css i have done i dont if this helps you or not but a small approach towards your question
input:focus + .head{
color: red;
}
<input>
<div class="head">highlight me</div>
Upvotes: 1
Reputation: 71
function highlight()
{
var div=document.getElementById("higlightDiv");
div.style.color="red";
}
div{
color:blue;
}
<div id="higlightDiv">highlight me</div><div><input type="text" onfocus="highlight();" /></div>
You can do it like this with javascript I guess
Upvotes: 0