$(document).load(); $(document).ready();的执行顺序
2013-06-06 12:36
417 查看
$(document).load();
当web页面以及其附带的资源文件,如CSS,Scripts,图片等,加载完毕后执行此方法。
常用于检测页面(及其附带资源)是否加载完毕。
$(document).ready();
当页面DOM对象加载完毕,web浏览器能够运行JS时,此方法即被触发。如果你想尽快执行JS,可以使用此方法。[在html的头部的script标签中的,不处于ready()中的JS代码将早于ready()执行]
$(document).unload();
此事件在停止浏览页面的时候触发,此操作可能存在于刷新操作/F5,单击上一页按钮,进入其他页面或关闭整个tab或窗口。
总而言之,他们的调用顺序是 ready() >> load() >> unload() 。
Will execute after the page along with all its contents are done loading. This means that all images, CSS (and content defined by CSS like custom fonts and images), scripts, etc. are all loaded. This happens event fires when your browser's "Stop" -icon becomes
gray, so to speak. This is very useful to detect when the document along with all its contents are loaded.
This on the other hand will fire as soon as the web browser is capable of running your JavaScript, which happens after the parser is done with the DOM. This is useful if you want to execute JavaScript as soon as possible.
This event will be fired when you are navigating off the page. That could be Refresh/F5, pressing the previous page button, navigating to another website or closing the entire tab/window.
To sum up, ready() will be fired before load(), and unload() will be the last to be fired.
http://stackoverflow.com/questions/2683072/jquery-events-load-ready-unload
当web页面以及其附带的资源文件,如CSS,Scripts,图片等,加载完毕后执行此方法。
常用于检测页面(及其附带资源)是否加载完毕。
$(document).ready();
当页面DOM对象加载完毕,web浏览器能够运行JS时,此方法即被触发。如果你想尽快执行JS,可以使用此方法。[在html的头部的script标签中的,不处于ready()中的JS代码将早于ready()执行]
$(document).unload();
此事件在停止浏览页面的时候触发,此操作可能存在于刷新操作/F5,单击上一页按钮,进入其他页面或关闭整个tab或窗口。
总而言之,他们的调用顺序是 ready() >> load() >> unload() 。
$(document).load();
Will execute after the page along with all its contents are done loading. This means that all images, CSS (and content defined by CSS like custom fonts and images), scripts, etc. are all loaded. This happens event fires when your browser's "Stop" -icon becomes
gray, so to speak. This is very useful to detect when the document along with all its contents are loaded.
$(document).ready();
This on the other hand will fire as soon as the web browser is capable of running your JavaScript, which happens after the parser is done with the DOM. This is useful if you want to execute JavaScript as soon as possible.
$(document).unload();
This event will be fired when you are navigating off the page. That could be Refresh/F5, pressing the previous page button, navigating to another website or closing the entire tab/window.
To sum up, ready() will be fired before load(), and unload() will be the last to be fired.
http://stackoverflow.com/questions/2683072/jquery-events-load-ready-unload
相关文章推荐
- JQ中$(window).load和$(document).ready区别与执行顺序
- Page_Load、Page_Init、$(document).ready,这三个的执行顺序
- Page_Load、Page_Init、$(document).ready,这三个的执行顺序
- JQ中$(window).load和$(document).ready区别与执行顺序
- jquery $(document).ready()和$.load执行顺序
- js在页面中的加载顺序及多个jquery $(document).ready() 的执行顺序
- 多个$(document).ready()函数的执行顺序
- 多个$(document).ready()的执行顺序
- jquery mobile在页面加载时添加加载中效果 document.ready 和window.onload执行顺序比较
- window.onload和$(document).ready()的加载执行顺序
- jQuery mobile在页面加载时添加加载中效果 document.ready 和window.onload执行顺序比较
- js常见执行方法$(document).load(),$(document).ready()
- $(document).ready(function()和 $(function()执行顺序
- Js&jQuery 执行顺序-ready&load&unload
- 多个$(document).ready()的执行顺序实例分析
- 一、jQuery $(document).ready()执行顺序-------------二、jquery $(document).ready() 与window.onload的区别
- 多个$(document).ready()的执行顺序问题
- 多个$(document).ready()的执行顺序实例分析
- jQuery中的$(window).load()与$(document).ready()