码迷,mamicode.com
首页 > Windows程序 > 详细

$(document).ready vs. $(window).load

时间:2014-08-20 19:21:42      阅读:289      评论:0      收藏:0      [点我收藏+]

标签:io   strong   for   cti   div   html   line   htm   

jQuery offers two powerful methods to execute code and attach event handlers: $(document).ready and $(window).load. The document ready event executes already when the HTML-Document is loaded and the DOM is ready, even if all the graphics haven’t loaded yet. If you want to hook up your events for certain elements before the window loads, then $(document).ready is the right place.

1
2
3
4
$(document).ready(function() {
 // executes when HTML-Document is loaded and DOM is ready
 alert("document is ready");
});

The window load event executes a bit later when the complete page is fully loaded, including all frames, objects and images. Therefore functions which concern images or other page contents should be placed in the load event for the window or the content tag itself.

1
2
3
4
$(window).load(function() {
 // executes when complete page is fully loaded, including all frames, objects and images
 alert("window is loaded");
});

$(document).ready vs. $(window).load,布布扣,bubuko.com

$(document).ready vs. $(window).load

标签:io   strong   for   cti   div   html   line   htm   

原文地址:http://www.cnblogs.com/J-Mat/p/3925287.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!