Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

401
Views
animate's callback function (complete) executed at start?

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?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

You need to pass a function to call. Instead you are calling the function.

complete:  function() { alert('end ani'); } 
over 4 years ago · Santiago Trujillo Report

0

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.

http://api.jquery.com/animate

alert('start ani');
$('.cellcontent').animate({
     left: '-=190'
   },
   {
     easing: 'swing',
     duration: 5000,
     complete: function(){
        alert('end ani');
    }
});
over 4 years ago · Santiago Trujillo Report

0

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.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!