jQuery页面加载事件的顺序是什么? [英] what is the sequence of jquery pageload events?
问题描述
关于哪些事件以什么顺序发生(以及触发它们的原因)有什么好的指南?
are there any good guides as to which events happen in which order (and what triggers them)?
即:
$(document).ready
$(window).ready
$(window).onload
我还缺少其他任何(页面加载)事件吗?
are there any other (pageload) events that i'm missing?
推荐答案
-
document.ready
-很好的DOM元素- 由
DOMContentLoaded
在Mozilla/WebKit/Opera中触发 - 在IE中由
onreadystatechange
触发
- 由
document.ready
- DOM Elements good to go- Triggered by
DOMContentLoaded
in Mozilla/WebKit/Opera - Trigered by
onreadystatechange
in IE
- Triggered by
- 实际的
window.onload
事件,这是一个核心DOM事件,不是由jQuery创建的.
- The actual
window.onload
event, this is a core DOM event, not created by jQuery.
document.ready
发生在window.load
之前或之时...如果所有其他方法均失败,则document.ready
实际上是window.load
上的事件处理程序,您可以在此处查看源代码:
document.ready
happens before or when window.load
does...if all else fails, document.ready
is actually an event handler on window.load
, you can see the source code here: http://github.com/jquery/jquery/blob/master/src/core.js#L407
没有window.ready
,document.ready
是jQuery创建的特殊事件,仅针对document
而不是window
.
There isn't a window.ready
, document.ready
is a special event that jQuery creates, only for document
and not window
.
这篇关于jQuery页面加载事件的顺序是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!