Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在jquery中保持动画一段时间_Jquery_Jquery Ui - Fatal编程技术网

在jquery中保持动画一段时间

在jquery中保持动画一段时间,jquery,jquery-ui,Jquery,Jquery Ui,这是我在jquery document.ready函数中编写的代码。加载页面时,它在循环路径中移动一个div。div正在使用“pixel”类。现在,我想为假设3secs保留动画,以便在加载页面时不会看到任何动作,3秒后div应该开始移动。 这里是动画发生的时间段 var i =0; $(".pixel").each(function(){ $(this).animate({path: Paths[type][i] }, 4000) i++; }) 您可以使用setTimeout

这是我在jquery document.ready函数中编写的代码。加载页面时,它在循环路径中移动一个div。div正在使用“pixel”类。现在,我想为假设3secs保留动画,以便在加载页面时不会看到任何动作,3秒后div应该开始移动。 这里是动画发生的时间段

var i =0;
$(".pixel").each(function(){
    $(this).animate({path: Paths[type][i] }, 4000)
    i++;
})

您可以使用setTimeout:

setTimeout(function() {
    var i =0;
    $(".pixel").each(function(){
        $(this).animate({ path: Paths[type][i++] }, 4000);
    });
}, 3000);

谢谢你,伙计。实际上我以前也试过。不管怎样,我知道是哪里出了问题。代码中应该是“this.stop()”