ExampleChange background color of an input field when it loses focus (blur):
Try it yourself » |
The blur event occurs when an element loses focus.
The blur() method triggers the blur event, or specifies a function to run when a blur event occurs.
Tip: In newer browsers, the blur event can be used on all elements (not only form elements).
Trigger the blur event for the selected elements.
|
Try it yourself » |
Specifies a function to run when the blur event occurs for the selected elements.
|
Try it yourself » |
Parameter | Description |
---|---|
function | Optional. Specifies the function to run when the blur event occurs |