$(window).load()和$(document).ready()函数之间的区别 [英] Difference between $(window).load() and $(document).ready() functions

查看:106
本文介绍了$(window).load()和$(document).ready()函数之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery中的$(window).load(function() {})$(document).ready(function() {})有什么区别?

What is the difference between $(window).load(function() {}) and $(document).ready(function() {}) in jQuery?

推荐答案

  • document.ready是一个jQuery事件,它在DOM准备就绪时运行,例如所有元素都可以找到/使用,但不一定所有内容.
  • window.onload稍后(或在最坏/失败的情况下同时)在加载图像等时触发,因此,例如,如果您使用图像尺寸,则通常需要改用它.
    • document.ready is a jQuery event, it runs when the DOM is ready, e.g. all elements are there to be found/used, but not necessarily all content.
    • window.onload fires later (or at the same time in the worst/failing cases) when images and such are loaded, so if you're using image dimensions for example, you often want to use this instead.
    • 这篇关于$(window).load()和$(document).ready()函数之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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