开发者

Jquery help, looping an animation

i'm a jQuery noob, how do I loop this? If possible, can I neaten this up aswell so it works the same with less code?

$(document).ready(function() {
    speech_animation();
});

 function speech_animation(){  
    $( "#b-block_wrap" ).delay(1000).fadeIn(500).animate({ top: 0}, {duration: 500,});
    $( "#p-block_wrap" ).delay(2000).fadeIn(500).animate({ top: 0,}, {duration: 500,});
    $("#first_wrap").delay(5500).fadeOut(500);
    $( "#g-block_w开发者_高级运维rap" ).delay(6000).fadeIn(500).animate({ top: 0}, {duration: 500,});
    $( "#y-block_wrap" ).delay(7000).fadeIn(500).animate({ top: 0}, {duration: 500,});
    $("#second_wrap").delay(10500).fadeOut(500);
}   


You can use a call back in your last function call so that as soon as the last function call is finished, it would call itself.

$(document).ready(function() {
    speech_animation();
});

 function speech_animation(){  
    $( "#b-block_wrap" ).delay(1000).fadeIn(500).animate({ top: 0}, {duration: 500,});
    $( "#p-block_wrap" ).delay(2000).fadeIn(500).animate({ top: 0,}, {duration: 500,});
    $("#first_wrap").delay(5500).fadeOut(500);
    $( "#g-block_wrap" ).delay(6000).fadeIn(500).animate({ top: 0}, {duration: 500,});
    $( "#y-block_wrap" ).delay(7000).fadeIn(500).animate({ top: 0}, {duration: 500,});
    $("#second_wrap").delay(10500).fadeOut(500, speech_animation);//callback here
}   
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜