Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

onfocus

//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>
 
PREVIOUS NEXT
Tagged: #onfocus
ADD COMMENT
Topic
Name
2+3 =