日期:2014-05-16  浏览次数:20383 次

jQuery 动画animate完成后回调
JScript code

$('div').animate(width:'300px',300,function(){
    alert('ok');
});


这样是能正常回调的,但是我想要多个动画无队列执行完后回调就不行了,如:
JScript code

$('div').animate(width:'300px',{ duration: 300, queue: false });
$('span').animate(width:'300px',{ duration: 300, queue: false });
$('p').animate(width:'300px',{ duration: 300, queue: false },function(){
   alert('ok');
});




------解决方案--------------------
JScript code
    $('div').animate({
        width: '300px',
        duration: 300,
        queue: false
    });
    $('span').animate({
        width: '300px',
        duration: 300,
        queue: false
    });
    $('p').animate({
        width: '300px',
        duration: 300,
        queue: false
    }, function() {
        alert('ok');
    });

------解决方案--------------------
JScript code
//更加规范点的写法
$("div").animate({ width: '300px' }, { duration: 300, queue: false });
$("span").animate({ width: '300px' }, { duration: 300, quequ: false });
$("p").animate({ width: '300px' }, { duration: 300, queue: false, complete: function() { alert('OK'); } });