Home > Web Front-end > JS Tutorial > body text

Detailed explanation of the use of focusin and focusout in jquery

黄舟
Release: 2017-06-27 13:24:57
Original
1595 people have browsed it

jquery Use of focusin and focusout methods

focusin(fn)

Overview

Bind a processing function to the focusin event of each matching element.
This event is triggered when an element, or any element within it, gains focus. The difference between this and the focus event is that it can detect whether the child element has gained focus on the parent element.

Parameters
fnFunction is the processing function bound in the focusin event of each matching element.
Example
Description:
Will trigger after getting focusAnimation:

HTML code:

<p><input type="text" /> <span>focusout fire</span></p>
<p><input type="password" /> <span>focusout fire</span></p>jQuery 代码:
$("p").focusin(function() {
  $(this).find("span").css(&#39;
display
&#39;,&#39;inline&#39;).fadeOut(1000);
});
Copy after login

focusout(fn)
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
fnFunction is the processing 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 代码:
$("p").focusout(function() {
  $(this).find("span").css(&#39;display&#39;,&#39;inline&#39;).fadeOut(1000);
});
Copy after login


The above is the detailed content of Detailed explanation of the use of focusin and focusout in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!