jQuery页面加载事件的顺序是什么? [英] what is the sequence of jquery pageload events?

查看:330
本文介绍了jQuery页面加载事件的顺序是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于哪些事件以什么顺序发生(以及触发它们的原因)有什么好的指南?

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?

推荐答案

  1. document.ready-很好的DOM元素
    • DOMContentLoaded在Mozilla/WebKit/Opera中触发
    • 在IE中由onreadystatechange触发
  1. document.ready - DOM Elements good to go
    • Triggered by DOMContentLoaded in Mozilla/WebKit/Opera
    • Trigered by onreadystatechange in IE
  • 实际的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.readydocument.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屋!

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