how to combine these 2 jquery animations code into one
here is the code so far. what i want is first the #spider to easeOutBounce then start doing 开发者_如何学Gothis animation
$("#spider").animate({top:"-=20px"},1000).animate({top:"+=20px"}, 1000);
here is all the codes
$(document).ready(function() {
setTimeout("animation()",300);
});
function animation(){
spider();
}
function spider(){
$("#spider").animate({top: '200px' }, {queue:false, duration:600, easing:'easeOutBounce'});
$("#spider").animate({top:"-=20px"},1000).animate({top:"+=20px"}, 1000);
setTimeout("spider()",2000);
}
thanks
you mean callback ??
function spider(){
$("#spider").animate({top: '200px' }, 600, 'easeOutBounce',
function() {
$(this).animate({top:"-=20px"},1000).animate({top:"+=20px"}, 1000);
});
}
精彩评论