Javatpoint Logo
Javatpoint Logo

jQuery focusout() method

The focusout() method attaches a function to execute on the occurrence of the focusout event on an element or any element in it. The focusout event occurs whenever the element (or any element inside it) loses the focus. It is different from the blur() method, as the focusout() method also triggers when child elements of an element lose the focus.

The focusout() method is generally used with the focusin() method.

Syntax

This method accepts an optional parameter, which is defined as follows -

function: This is an optional parameter. It specifies a function to execute on the occurrence of the focusout event.

Now let's understand the focusout() method using an example.

Example

In this example, we are using the focusout() method together with the focusin() method. Here, there is a div element, including a textfield. When the user will click inside the textfield, the focusin event triggers, and on clicking outside the textfield, the focusout event triggers, and the textfield will lose its focus.

Test it Now

Output

jQuery focusout() method

After clicking inside the textfield, the output will be -

jQuery focusout() method

On clicking outside the textfield, the div element will lose its focus. After clicking outside the textfield, the output will be -

jQuery focusout() method





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA