如果条件,在两个之间添加延迟

时间:2013-05-08 12:52:46

标签: jquery html css

我想在两个函数之间添加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(),但它无效。我该怎么用?

1 个答案:

答案 0 :(得分:3)

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