javascriptjqueryjquery-animatejquery-effectsjquery-easing

jQuery animate not firing callback function


I have the following jQuery animate function:

$myDiv.animate({ "left": "0%" }, { duration: 1000, easing: 'easeInOutExpo' }, 
    function () {
        alert('hi');
    }
);

The animation itself works. $myDiv slides with the easeInOutExpo effect, as desired. However, the callback function is never fired. To test it, I changed the callback to just alert("hi");, as you can see above. Still doesn't work.

What could I be doing wrong?


Solution

  • Try this

    Demo: jsFiddle

      $("#myDiv").animate({ "left": "0%" }, { duration: 1000, easing: 'easeInOutExpo' , 
        complete:function () {
            alert('hi');
        }
       }
    );