how to control jquery animate speed

2019-02-26 15:14发布

i am working with jquery for animate a div. i want to control speed on moving. i played lot of with this. but i hope some one can tell me how can i control the speed. here is the code example.

$(document).ready(function(){
    $('#block').css({'left':'-617px','top':'-300px'});
    $('#Cont').show();
    $('#block').animate({'left':'17px','top':'10px'},'slow',function(){

    });
});

i want to know how can i control the speed on animation.

2条回答
女痞
2楼-- · 2019-02-26 15:22

The default duration is 400 milliseconds. The strings 'fast' and 'slow' corresponds to 200 and 600 milliseconds, respectively.

$('#block').animate({'left':'17px','top':'10px'},'slow',function(){


        });
查看更多
姐就是有狂的资本
3楼-- · 2019-02-26 15:24

just change slow with the time in milliseconds, e.g. for 1,2 seconds just do

$('#block').animate({'left':'17px','top':'10px'},  1200, function() {
...
查看更多
登录 后发表回答