jquery动画完成函数在动画执行之前执行

时间:2015-07-17 05:54:31

标签: javascript jquery

我想在动画完成后删除ul的li但是  它使li在完成前删除。请帮我解决一下该怎么做

$('#btnGo').click(function() {

  var $ulCust = $('#divCust ul');

  $ulCust.find('li:first').animate({
    opacity: 0.25,
    left: 915
  }, 'slow', function() {
    //this function executes before animation completes
    $('#btnGo').delay(2000).html('Complete'); //this delay is also not working                   
    console.log('complete');
    //$(this).delay(100000).remove();                

  });
 })
});

1 个答案:

答案 0 :(得分:0)

试试这个

$('#btnGo').click(function () {
    var $ulCust = $('#divCust ul');
    $ulCust.find('li:first').animate({
        opacity: 0.25,
        left: 915
        complete: function () {
            $('#btnGo').html('Complete');
        }
    });
});