【问题标题】:How to run code when jquery slideUp() finished?jquery slideUp()完成后如何运行代码?
【发布时间】:2017-01-24 11:30:22
【问题描述】:

有没有什么方法可以执行html(),只有当slideUp() 会执行完?

<p class="test">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tortor elit</p>
$(".test").slideUp().html("");

我试过用 Deferred 和 queue 来做,但我失败了。

【问题讨论】:

    标签: javascript jquery html slideup


    【解决方案1】:

    animation complete callback 内进行。

    $(".test").slideUp(function(){ 
      $(this).html(""); 
    });
    

    $(".test").slideUp(2000,function() {
      $(this).html("");
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <p class="test">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tortor elit</p>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-20
      • 2012-06-13
      相关资源
      最近更新 更多