Description
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 occur.
Tip: In newer browsers, the blur event can be used on all elements (not only form elements)
Trigger the Event
Trigger the blur event for the selected elements.
v1.0
This method has the form:
.blur()
Return Value
This form returns a jQuery object.
Bind a Function to the Event
Specifies a function to run when the blur event occurs for the selected element.
v1.0
This method has the alternative form:
.blur(function)
Parameter | Description |
---|---|
function | (optional) Specifies the function to run when the blur event occurs |
Return Value
This form returns a jQuery object.
v1.4.3
This method has the alternative form:
.blur(data,function)
Parameter | Description |
---|---|
data | (optional) Specifies additional data to pass along to the function |
function | (optional) Specifies the function to run when the blur event occurs |
Return Value
This form returns a jQuery object.
Examples
Change background color of an input field when it loses focus (blur):
$("input").blur(function(){
$("input").css("background-color","#D6D6FF");
});