Search...
onFocus( )
Adds an event handler that runs when the element receives focus.
Description
An element receives focus through user actions, such as clicking and tabbing, or programmatically, using the focus( ) function.
You can also define an event handler using the Properties and Events panel.
Note:
onFocus()
has no effect when applied to RadioButtonGroup elements.
Syntax
function onFocus(handler: EventHandler): Elementhandler: function EventHandler(event: Event): void
onFocus Parameters
NAME
TYPE
DESCRIPTION
handler
The name of the function or the function expression to run when the element receives focus.
EventHandler Parameters
NAME
TYPE
DESCRIPTION
Returns
This function does not return anything.
Return Type:
void
Mixed in from:$w.FocusMixin
Was this helpful?
Get the ID of the element that has received focus
Copy Code
1$w("#myElement").onFocus( (event) => {2 let targetId = event.target.id; // "myElement"3});