Is it possible when you focus the input to change the border color of the parent?

<div class="input_group">
<span class="icon">...</span>
<input class="specification" type="text" size="35" name="specification_10" id="specification_10" value="" maxlength="255">
</div>


Hello!
Is it possible when you focus the input to change the properties .input_group?
Thank you!
March 19th 20 at 08:30
2 answers
March 19th 20 at 08:32
Solution
No, children can't put on the parent. But you can use + or ~, that's the way

ie create a separate element "background", on the same level as the input field. And by using this selector
.specification:focus ~ .input_back
assign the styles for the background when the input field is in focus.
@Ethel_Kuvali thank you very much for the help! It worked. - camryn57 commented on March 19th 20 at 08:35
March 19th 20 at 08:34
If only CSS, no

In jquery, you can
$('.specification').on('focus', function(){
 $(this).parent('.input_group').css('border', '1px solid red');
});

Find more questions by tags CSS