本文介绍了jquery focusout事件丢失相关的目标信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本输入绑定到 focusin / focusout 事件。

i have a text input that is bound to focusin/focusout events.

$(element)
    .focusin(function(e) {})
    .focusout(function(e) {
        var to = e.relatedTarget || e.toElement;
        // undefined in chrome, fine in IE
    });

on focusout ,我有兴趣 relatedTarget 信息,即DOM元素在文本输入失去焦点时接收焦点,但是该属性为 undefined for

on focusout, i'm interested in the relatedTarget information, i.e., the DOM element receiving focus as the text input loses focus, however this property is undefined for the event.

另一方面, toElement ,我相信是互联网浏览器等价于 relatedTarget 可用。换句话说,我的 focusout 处理程序在IE中正常工作,但不在其他浏览器中。

on the other hand, toElement, which i believe is the internet explorer equivalient of relatedTarget, is available. in other words, my focusout handler works fine in IE, but not in other browsers.

是否有解决方法对于上述限制?

is there a workaround for the above limitation?

推荐答案

从:

focusout 不是一个鼠标事件,所以 relatedTarget 未设置。 IE不符合这里的标准(新功能)。

focusout is not a mouse event, so relatedTarget is not set. IE is not following standards here (what's new?).

这篇关于jquery focusout事件丢失相关的目标信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 06:32