javascript - jquery animate Complete 函数在动画完成之前执行

标签 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();                

  });
 })
});

最佳答案

试试这个

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

关于javascript - jquery animate Complete 函数在动画完成之前执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31469182/

相关文章:

javascript - 无法在 'getElementById' html 元素上使用 'span'

javascript - Spring-boot删除javascript确认消息

jquery - 在其他对话框打开时更改 jquery 对话框标题的颜色,我们不希望它们更改

javascript - 如何修改带幻灯片效果的饼图大小

php - ajax 加载数据的 Jquery 分页

javascript - 在没有提交按钮的情况下提交最接近的表单?

javascript - 在一页上 Bootstrap 多个轮播

javascript - 为什么我不能为新的 Image 对象分配属性?

javascript - 如何使用 promise 链接多个 setTimeout 函数?

jQuery悬停方法?