onfocus Event in JavaScript
onfocus Event in JavaScript
The onfocus attribute fires the moment that the element gets focused. It is mostly used on input and select elements. However, we can apply it to all HTML elements. Its opposite event is onblur. In this event, the element loses focus
Syntax:-
Its syntax is:- < anyElement onfocus="my_script" > OR object.onfocus= function(){my_script} OR object.addEventListener("focus", my_script)