0

我正在添加一个带有 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>
4

2 回答 2

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

于 2013-11-15T19:39:53.437 回答
0

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

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

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

于 2010-12-09T01:54:27.877 回答