手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jQuery ready()和onload的加载耗时分析
jQuery ready()和onload的加载耗时分析
摘要:本文实例讲述了jQueryready()和onload的加载耗时。分享给大家供大家参考,具体如下:varstartTime=newDate(...

本文实例讲述了jQuery ready()和onload的加载耗时。分享给大家供大家参考,具体如下:

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="js/jquery-1.10.1.min.js" type="text/javascript"></script> <script type="text/javascript"> var startTime = new Date().getTime(); $(document).ready(function(){ test1(); }) function test1(){ var endTime2 = new Date().getTime(); var a = endTime2 - startTime; $("<div>jQuery的ready() : "+a+" ms</div>").appendTo("body"); } function test2(){ var endTime1 = new Date().getTime(); var b = endTime1 - startTime; $("<p>JavaScript的window.onload : "+b+" ms</p>").appendTo("body"); } </script> </head> <body onload="test2();"> <img src="img/demo.jpg"/> </body> </html>

效果图如下:

jQuery ready()和onload的加载耗时分析1

希望本文所述对大家jQuery程序设计有所帮助。

【jQuery ready()和onload的加载耗时分析】相关文章:

jQuery中 prop() attr()使用详解

jQuery实现dialog设置focus焦点的方法

jQuery+ajax实现无刷新级联菜单示例

javascript获取select值的方法分析

javascript带回调函数的异步脚本载入方法实例分析

jquery实现用户打分评分特效

jQuery的基本概念与高级编程

多种js图片预加载实现方式分享

浅谈jQuery构造函数分析

jquery滚动特效集锦

精品推荐
分类导航