【问题标题】:Finish "transfer" before adding text在添加文本之前完成“传输”
【发布时间】:2013-11-16 03:39:53
【问题描述】:

我正在添加一个带有 jquery 效果传输的列表。我想让文本-“元素”仅在传输效果完全完成后出现。任何想法?谢谢,

<script type="text/javascript">
$(document).ready(function(){
    $("#add-li").click(function(){
        var NewLI = document.createElement("li");
        var ul = document.getElementById("ul");
        NewLI.innerHTML = 'element';
        ul.appendChild(NewLI);

        $("#add-li").effect("transfer", { to: $("#ul li:last-child"), className: "ui-effects-transfer" }, "slow");
        })})
</script>
<style type="text/css">
.ui-effects-transfer { border: 2px dotted #FFE600; }
</style>
</head>

<body>
<p><input type="button" id="add-li" value="add list" /></p>
<br /><br /><br /><br /><br /><br /><br />
<p>
    <div id="effect">Below this the list.
    <ul id="ul">
    </ul>
    </div>
</p>
</body>

【问题讨论】:

    标签: jquery effect transfer


    【解决方案1】:

    是的,但不要忘记 jQuery deferred ;)
    这是一个如何实现回调的快速示例代码。

    $( "div" ).click(function() {
      var html1 = $(this).clone();  
      var i = 1 - $( "div" ).index( this );
      $( this ).effect( "transfer", { to: $( "div" ).eq( i ) }, 1000 ).promise().done(function(){
        $( "div" ).eq( i ).html(html1.html());
        $(this).empty();
      });
    
    });
    

    试试这个: http://jsbin.com/oSuZoDaK/2/edit

    【讨论】:

      【解决方案2】:

      这太糟糕了!您使用的效果似乎没有回调选项。 http://docs.jquery.com/UI/Effects/Transfer

      这个有回调http://api.jquery.com/animate/

      更多关于回调http://api.jquery.com/slideDown/的例子

      【讨论】:

        猜你喜欢
        • 2011-07-05
        • 1970-01-01
        • 1970-01-01
        • 2016-12-22
        • 2021-08-02
        • 1970-01-01
        • 2014-10-02
        • 1970-01-01
        • 2018-07-29
        相关资源
        最近更新 更多