CodeOverload
CodeOverload

Reputation: 48505

jQuery: Remove Div after 2 combined animations done?

i have a jQuery line that execute 2 animations, what i want is to remove the #flasher DIV after sliding it up by my current code. How to add a callback in this bunch of brackets?

here is my code:

$("#flasher").animate({opacity: 1.0}, 6000).animate({"top": "-=30px"},"slow");

Thanks

Upvotes: 0

Views: 175

Answers (3)

Flatlin3
Flatlin3

Reputation: 1659

this should to it

$("#flasher").animate({opacity: 1.0}, 6000).animate({"top": "-=30px"},"slow", function() {
    $("#flasher").remove();
});

Upvotes: 1

Giorgi
Giorgi

Reputation: 30883

You need to add callback function as the next parameter in last call to animate. The animate api page has some examples.

Upvotes: 0

PetersenDidIt
PetersenDidIt

Reputation: 25620

$("#flasher").animate({opacity: 1.0}, 6000)
.animate({"top": "-=30px"},"slow",function(){
    $(this).remove();
});

Upvotes: 1

Related Questions