在jQuery中,focusin / focusout与focus / blur有什么区别? [英] What is the difference between focusin/focusout vs focus/blur in jQuery?

查看:137
本文介绍了在jQuery中,focusin / focusout与focus / blur有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆