.animate回调函数后的.done [英] .done after .animate callback function

查看:137
本文介绍了.animate回调函数后的.done的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在.animate回调函数之后调用一个函数.我为此使用.done方法,但无法正常工作. 小提琴

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)})
})

推荐答案

您在按钮元素上调用了done,而不是在动画的div上调用了

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)
    })
})

演示:小提琴

这篇关于.animate回调函数后的.done的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆