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
Difference between the javascript/jQuery events "focus" and "focusin"?
提问by Randomblue
What is the difference between these two events: focus
and focusin
?
这两个事件之间有什么区别:focus
和focusin
?
回答by shabunc
The focusin
eventis 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 focusout
event.
此事件可能会与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 事件将发送到该元素。这与焦点事件的不同之处在于它支持检测父元素上的焦点事件(换句话说,它支持事件冒泡)。
回答by FishBasketGordo
According to the jQuery focusin
documentation:
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 事件将发送到该元素。这与焦点事件的不同之处在于它支持检测父元素上的焦点事件(换句话说,它支持事件冒泡)。