手机
当前位置:查字典教程网 >编程开发 >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表单暂存功能插件分享

jquery实现点击label的同时触发文本框点击事件的方法

jquery实现用户打分评分特效

javascript获取select值的方法分析

jQuery处理图片加载失败的常用方法

window.onload与$(document).ready()的区别分析

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

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

AspNet中使用JQuery boxy插件的确认框

jQuery结合ajax实现动态加载文本内容

精品推荐
分类导航