I want call a function after .animate callback function. I am using .done method for this purpose but it is not working. fiddle
$(function(){
$('button').click(function(){
$('div').animate({width:'400px'},300,function(){alert(0)})
}).promise().done(function(){alert(1)})
})
You were calling the done
on the button element, not on the div
which is animated
$('button').click(function () {
$('div').animate({
width: '400px'
}, 300, function () {
alert(0)
}).promise().done(function () {
alert(1)
})
})
Demo: Fiddle
You need to put the promise on the animate
function. At the minute, you have it on the .click
:
$('button').click(function(){
$('div').animate({width:'400px'},300,function(){alert(0)})
.promise()
.done(function(){alert("1")});
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With