Home >Web Front-end >JS Tutorial >The use and definition of jQuery focusout event
Overview
Bind a handler function to the focusout event of each matching element.
This event is triggered when an element, or any element within it, loses focus. The difference between this and the blur event is that it can detect when the child element loses focus on the parent element.
Parameters
fnFunctionV1.0
The handler function bound in the focusout event of each matching element.
[data],fnString,FunctionV1.4.3
data:focusout([Data], fn) can pass in data for Function fn processing.
fn: The handler function bound in the focusout event of each matching element.
Example
Description:
Animation will be triggered after losing focus:
HTML code:
<p><input type="text" /> <span>focusout fire</span></p> <p><input type="password" /> <span>focusout fire</span></p>
jQuery Code:
$("p").focusout(function() { $(this).find("span").css('display','inline').fadeOut(1000); });
Example
When the dc6dce4a544fdca2df29d5ac0ea9906b element or any of its sub-elements loses focus, set the background color of the dc6dce4a544fdca2df29d5ac0ea9906b element:
$("div").focusout(function(){ $(this).css("background-color","#FFFFFF"); });
Definition and Usage
The focusout event occurs when an element (or any element within it) loses focus.
The focusout() method adds a function to run when the focusout event occurs on the element or any element within it.
Different from the blur() method, the focusout() method will also be triggered when any sub-element loses focus.
Tip: This method is usually used together with the focusin() method.
The above is the detailed content of The use and definition of jQuery focusout event. For more information, please follow other related articles on the PHP Chinese website!