Reputation: 8360
I have a jQuery animate function. A need to execute a function as soon as animation ends. So gotta use callback function. So I tried it. Didn't work, I thought there must be problem in that particular function so I reduced it to simply this...
phGrp.animate({bottom:0},
{duration: 1500, easing: 'swing'},
function(){alert('hello')}
);
Animation works correctly, no error, but callback won't execute. What can be the problem? I saw a solution of using anonymous function. So I have used it, but still problem persists.
Please help
Upvotes: 2
Views: 5956
Reputation: 2113
also, make sure you don't have any transition
rule in the CSS, it made me crazy!
Upvotes: 4
Reputation: 86403
The problem is that the callback function needs to be inside with options
.animate( properties, options )
(ref, options = duration, easing, complete, etc)
phGrp.animate(
{
bottom:0
},
{
duration : 1500,
easing : 'swing',
complete : function(){ alert('hello') }
});
Upvotes: 5
Reputation: 124
Maybe you have to call jquery in this way
$(document).ready(function(){
// your code;
});
Upvotes: 1
Reputation: 18568
try something like below, check the fiddle it is working
phGrp.animate({bottom:0},1500,'swing',
function(){alert('hello');
}
);
fiddle : http://jsfiddle.net/hYtuP/
for refrence check the link : http://api.jquery.com/animate/
Upvotes: 5