2013-05-08 44 views
0

我想在两个函数之间添加wait()或延迟。在两个条件之间添加延迟

function(imageID) 
    { 
     //alert("i main slider called "); 

     if(en==1) 
     { 
      var selected=$('#' + sel); 
      $(selected).animate({"left": "+=30px","opacity": "0.99"},"slow"); 
      $(selected).animate({"height":"354px","width":"295px"},30); 
      $(selected).css("-webkit-transform-style","preserve-3d"); 
      $(selected).css("-webkit-transition","all 1.0s linear"); 
      $(selected).css("transform-style","preserve-3d"); 
      $(selected).css("transition","all 1.0s linear"); 
      $(selected).css("-webkit-transform","rotateY(0deg)"); 
      $(selected).css("transform","rotateY(0deg)"); 
      en=0; 
     } 

     if(my.circular) 
     { 
      /* Trigger left jumppoint */ 
      if(imageID+1 === my.imageFocusMax) 
      { 
       /* Set jump target to the same cloned image on the right */ 
       clonedImageID = my.max - my.imageFocusMax; 
       jumpTarget = -clonedImageID * my.xStep; 

       /* Set the imageID to the last image */ 
       imageID = clonedImageID-1 ; 
      } 

在我的函数中,我想在if语句之后添加一个delar。我怎样才能做到这一点?我曾尝试添加delay(),但它不起作用。我应该使用什么?

+0

使用'的setTimeout()' – Santosh 2013-05-08 12:55:14

+0

看看这个链接http://stackoverflow.com/questions/1183872/put-a-delay-in-javascript – Santosh 2013-05-08 12:55:42

+0

下面是解 http://stackoverflow.com/问题/ 4437600/sleep-in-jquery – 2013-05-08 12:56:11

回答

3

使用setTimeout函数。这样你可以告诉浏览器在做某事之前等待。