延迟jquery,ready事件触发的时间

 1     $.holdReady(true);//holdReady必须在ready()方法调用之前来调用,来延迟ready()方法的执行
 2 
 3     $(document).ready(function(){
 4         console.log("开始执行。");
 5         $("div:odd").mouseover(function(){
 6             $(this).css({"width":"100px","height":"200px","background":"blue"});
 7         }).mouseout(function(){
 8             $(this).css("opacity","0.5");
 9         })
10     });
11 
12     setTimeout(function(){
13         console.log("执行成功。");
14         $.holdReady(false);//通过定时器来执行
15     },5000);
16     //这里holdReady(true)和holdReady(false)调用的次数必须相同

 

posted @ 2016-03-07 22:26  Window2016  阅读(523)  评论(0编辑  收藏  举报