javascript/jQuery 事件“focus”和“focusin”之间的区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7311143/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 01:44:11  来源:igfitidea点击:

Difference between the javascript/jQuery events "focus" and "focusin"?

javascriptjquery

提问by Randomblue

What is the difference between these two events: focusand focusin?

这两个事件之间有什么区别:focusfocusin

回答by shabunc

The focusineventis sent to an element when it, or any element inside of it, gains focus. This is distinct from the focus event, in that it supports detecting the focus event on parent elements (in other words, it supports event bubbling).

focusin事件被发送到一个元素时,或在其内部的任何元素,获得焦点。这与焦点事件不同,因为它支持检测父元素上的焦点事件(换句话说,它支持事件冒泡)。

This event will likely be used together with the focusoutevent.

此事件可能会与focusout事件一起使用。

回答by Jared Farrish

The focusin event is sent to an element when it, or any element inside of it, gains focus. This is distinct from the focus event in that it supports detecting the focus event on parent elements (in other words, it supports event bubbling).

当元素或其中的任何元素获得焦点时,focusin 事件将发送到该元素。这与焦点事件的不同之处在于它支持检测父元素上的焦点事件(换句话说,它支持事件冒泡)。

http://api.jquery.com/focusin/

http://api.jquery.com/focusin/

回答by FishBasketGordo

According to the jQuery focusindocumentation:

根据jQueryfocusin文档

The focusin event is sent to an element when it, or any element inside of it, gains focus. This is distinct from the focus event in that it supports detecting the focus event on parent elements (in other words, it supports event bubbling).

当元素或其中的任何元素获得焦点时,focusin 事件将发送到该元素。这与焦点事件的不同之处在于它支持检测父元素上的焦点事件(换句话说,它支持事件冒泡)。