在 Web 浏览器中,onblur 和 onfocusout 之间有什么区别? [英] In web browsers, what's the difference between onblur and onfocusout?

查看:25
本文介绍了在 Web 浏览器中,onblur 和 onfocusout 之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果它们是一样的,那为什么会有两个这样的事件?

If they're the same, then why there are two of this kind of event?

推荐答案

如您所知,onBlur 事件会针对该元素触发,如果该元素具有焦点但又失去焦点.

As you know, the onBlur event fires for an element if that element had the focus, but loses it.

onFocusOut 事件在这种情况下会触发,但也会在任何子元素失去焦点时触发.

The onFocusOut event fires in this case, but also triggers if any child element loses focus.

例如,您有一个具有特殊格式的 div,因为人类当前正在编辑该区域中的一个字段.当焦点离开该 div 时,您可以使用 onFocusOut 关闭该格式.

For example, you have a div with special formatting because the human is currently editing a field in that area. You'd could use onFocusOut to turn that formatting off when focus leaves that div.

直到最近,onFocusOut 仅被 IE 使用.如果这种情况发生了变化,那是最近的事情.在 FF、Chrome 等中测试

Up until very recently, onFocusOut was only used by IE. If that has changed, it has been very recent. Test in FF, Chrome, etc.

这篇关于在 Web 浏览器中,onblur 和 onfocusout 之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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