在jQuery中,focusin / focusout与focus / blur有什么区别? [英] What is the difference between focusin/focusout vs focus/blur in jQuery?
问题描述
我使用以下代码使用 jQuery 1.7.2 处理一些事件:
I was handling some events using the following code with jQuery 1.7.2:
$().on('focus blur', function(event) {
console.log(event.type);
});
我注意到 event.type
对于这两个事件,打印输出: focusin
和 focusout
。
And I have noticed that event.type
for both events, prints out: focusin
and focusout
.
focusin / focusout
与焦点/模糊
之间有什么区别?
推荐答案
简答: focusin
bubbles,焦点
没有。
focusout
bubbles, blur
没有。
阅读 docs :
Short answer: focusin
bubbles, focus
does not.
focusout
bubbles, blur
does not.
Read the docs:
当focusin事件或其中的任何元素获得焦点时,focusin事件将被发送到元素。这与焦点事件的不同之处在于它支持检测父元素上的焦点事件(换句话说,它支持事件冒泡)。
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).
这篇关于在jQuery中,focusin / focusout与focus / blur有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!