Reputation: 13843
Here is the jQuery I've written to animate some items in a list:
$("#titleTile").delay(5000).animate({top: "160px"}, 300, function() {
$(".tweet_msg.t0").animate({top: 0, height: "show"}, 300, function() {
$(".tweet_msg.t1").delay(5000).animate({top: 0, height: "show"}, 300, function() {
$(".tweet_msg.t2").delay(5000).animate({top: 0, height: "show"}, 300, function() {
$(".tweet_msg.t3").delay(5000).animate({top: 0, height: "show"}, 300, function() {
$(".tweet_msg.t4").delay(5000).animate({top: 0, height: "show"}, 300);
});
});
});
});
});
Is there a better way to write my code?
Secondly can I wrap it up into a function that I could call?
Upvotes: 1
Views: 69
Reputation: 78650
The other option would be to use a custom queue on a single element. May be overkill if this is all you are doing. But if you want to, here is a small example I had created for a previous question:
As far as wrapping it in a function, sure, just wrap it in a function:
function something(){
// do your stuff
}
Upvotes: 3