onfocus event
The onfocus event activates when an element receives focus. Â The event can be specified as a JavaScript expression or the name of a JavaScript function. Â
If an expression is used, the JavaScript keyword this refers to the element that received focus. Â
If the name of a function is used, the function will receive 2 parameters when called:Â
The browser event object
A reference to the element that received focus
Example:
The following would draw a red border around the element once it receives focus.
onfocus:Â this.style.border = "1px solid red";