//The onfocus event occurs when an element gets focus
Enter your name: <input type="text" onfocus="myFunction(this)">
<p>input field gets focus & a function is triggered changes the background-color.</p>
<script>
function myFunction(x) {
x.style.background = "yellow";
}
</script>