哪些jQuery事件不会冒泡? [英] Which jQuery events do not bubble?

查看:212
本文介绍了哪些jQuery事件不会冒泡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很简单,我一直在高低搜寻所有不会冒泡的jQuery事件的完整列表,但是我一直找不到.

Pretty straightforward, I've been searching high and low for a comprehensive list of all jQuery events that do not bubble but I have been unable to find one.

例如,我正在寻找image.loadXMLHttpRequest.error等事件.

For example I am looking for events like image.load, XMLHttpRequest.error, etc.

推荐答案

jQuery的文档on()方法是这样的(在附加说明"下);

The docs for jQuery's on() method says this (under "Additional Notes");

W3C将focusblur事件指定为不冒泡,但是jQuery定义了确实会冒泡的跨浏览器focusinfocusout事件.当focusblur用于附加委托的事件处理程序时,jQuery映射名称并将其分别作为focusinfocusout传递.为了保持一致和清晰,请使用冒泡事件类型名称.

The focus and blur events are specified by the W3C to not bubble, but jQuery defines cross-browser focusin and focusout events that do bubble. When focus and blur are used to attach delegated event handlers, jQuery maps the names and delivers them as focusin and focusout respectively. For consistency and clarity, use the bubbling event type names.

在所有浏览器中,loadscrollerror事件(例如,在<img>元素上)不会冒泡.在Internet Explorer 8及更低版本中,pastereset事件不会冒泡.不支持将此类事件与委托一起使用,但是当事件处理程序直接附加到生成元素时可以使用这些事件.事件.

In all browsers, the load, scroll, and error events (e.g., on an <img> element) do not bubble. In Internet Explorer 8 and lower, the paste and reset events do not bubble. Such events are not supported for use with delegation, but they can be used when the event handler is directly attached to the element generating the event.

我已经加上最相关的句子以供强调.

I've bolded the most relevant sentences for emphasis.

文档中的较早版本(在直接和委托的事件"下,它也这样说:

Earlier in the docs (under "direct and delegated events", it also says this:

在Internet Explorer 8及更低版本中,诸如changesubmit之类的一些事件本身并不是冒泡的,但是jQuery修补了这些事件以冒泡并创建一致的跨浏览器行为.

In Internet Explorer 8 and lower, a few events such as change and submit do not natively bubble but jQuery patches these to bubble and create consistent cross-browser behavior.

您还将发现 mouseleave

You'll also find that mouseleave and mouseenter do not bubble (use the mouseover and mouseout events for that). This is discussed in their respective docs.

我不会开始全面地提及上述列表,但这只是一个开始.我不确定XMLHttpRequest如何进入您的问题;它不是DOM的一部分,因此没有任何祖先,因此不能像普通DOM事件一样真正地冒泡.

I wouldn't begin to call the above list comprehensive, but it's a start. I'm not sure how XMLHttpRequest comes into it in your question; it isn't part of the DOM, therefore doesn't have any ancestors, therefore cannot really bubble in the same way as normal DOM events.

这篇关于哪些jQuery事件不会冒泡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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