I have two input box inside a div of position absolute. And a label on those input boxes. The effect I want is when i focus one input box then the label should be blue color and when blurred should be removed the class (blue color). And simultaneously the other label and input box too.
// Initial color of label
label.labels{
color: black;
}
input.box{
border-width: 0 0 2px 0;
outline: none;
}
<div style = "position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto;">
<label class = "labels">First Name:</label>
<input type = "text" class = "box" /><br />
<label class = "labels">Last Name:</label>
<input type = "text" class = "box" />
</div>
When i focus the input.box then label.labels color should be blue. And ya, both the input and both the labels have same classes. How to achieve this effect with Pure Javascript? Or if possible please tell me how can i achieve this with css?