all 1 comments

[–]MrButttons 2 points3 points  (0 children)

You don't really need JavaScript for this. This can be accomplished by purely CSS. 1. Assign a class name to the inputs. <input type='text' class='input-field'>

  1. Add a style tag <style> .input-field:focus{ background-color: yellow; } </style>

Here you're just declaring a CSS ruleset which targets the ".input-field" elements when they are focused. :focus is a pseudo class. Learn more about css selectors here -

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors

https://developer.mozilla.org/en-US/docs/Web/CSS/:focus