前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【jQuery】window.onload 和 $(document).ready() 的区别

【jQuery】window.onload 和 $(document).ready() 的区别

作者头像
zhaokang555
发布2023-10-17 09:16:34
1030
发布2023-10-17 09:16:34
举报

...

在Stack Overflow上看到了这个问题,自己翻译了过来。


The onload event is a standard event in the DOM, while the ready event is specific to jQuery. 

window.onload 是DOM中的标准事件,而$(document).ready() 是jQuery中的事件。(显然......)


The ready event occurs after the HTML document has been loaded, while the onload event occurs later, when all content (e.g. images) also has been loaded.

当HTML document 载入完毕后,ready 事件发生。但是,onload 事件发生的比ready 更晚。当网页上所有的内容(content)载入完毕后(包括图片),onload 事件才会发生。


The purpose of the ready event is that it should occur as early as possible after the document has loaded, so that code that adds functionality to the elements in the page doesn't have to wait for all content to load.

ready 事件的目的是:在document 装载完成之后,ready 事件应该尽可能早的发生。以便于给elements 添加功能,而不用等所有的content 都装载完成。


...

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-02-16,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档