I'm using jQuery 1.5.1 This is my code:
$('.cellcontent').animate({
left: '-=190'}, {
easing: alert('start ani'),
duration: 5000,
complete: alert('end ani')});
I get both alerts before the animation starts!? I want the complete function to start after the animation has ended. Any thoughts?
You need to pass a function to call. Instead you are calling the function.
complete: function() { alert('end ani'); }
I see two things wrong with this.
One, easing should be:
A string indicating which easing function to use for the transition
And complete should be a function.
alert('start ani');
$('.cellcontent').animate({
left: '-=190'
},
{
easing: 'swing',
duration: 5000,
complete: function(){
alert('end ani');
}
});
You need to pass a function to complete.
Try this:
$('.cellcontent').animate({
left: '-=190'}, {
easing: alert('start ani'),
duration: 5000,
complete: function() { alert('end ani') }
});
Since complete expects a function, it executes the code you pass to it to get a function object that it can call back to when finished.