Jquery 在克隆和删除功能上应用动画

Jquery 在克隆和删除功能上应用动画,jquery,jquery-animate,Jquery,Jquery Animate,我的页面上有克隆和删除功能,我想分别对其应用slideDown/slideUp动画: $('#add-item').click(function(){ var divCloned = $('.form-fields:first').clone(); divCloned.insertAfter('.form-fields:last'); return false; }); $('.remove').live('click', function(){ if(conf

我的页面上有克隆和删除功能,我想分别对其应用slideDown/slideUp动画:

$('#add-item').click(function(){
    var divCloned = $('.form-fields:first').clone();
    divCloned.insertAfter('.form-fields:last');
    return false;
});

$('.remove').live('click', function(){
    if(confirm("Are you sure you wish to remove this item?"))
    {
        $(this).parent().remove();
    }
    return false;
});
我试过这样做,但要么不起作用,要么动画很不稳定。有人知道如何做到这一点吗?

用于克隆

$('#add-item').click(function(){
    var divCloned = $('.form-fields:first').clone();
    // first we hide it (set display to none), then we add it in the DOM 
    // and lastly we aninmate it with slideDown
    divCloned.hide().insertAfter('.form-fields:last').slideDown('fast');
    return false;
});
至于删除

$('.remove').live('click', function(){
    if(confirm("Are you sure you wish to remove this item?"))
    {
        // we use the callback method of the slideUp function
        // so that the removal happens after the animation..
        $(this).parent().slideUp('fast',function(){ $(this).remove(); });
    }
    return false;
});

进行克隆演示

$('#add-item').click(function(){
    var divCloned = $('.form-fields:first').clone();
    // first we hide it (set display to none), then we add it in the DOM 
    // and lastly we aninmate it with slideDown
    divCloned.hide().insertAfter('.form-fields:last').slideDown('fast');
    return false;
});
至于删除

$('.remove').live('click', function(){
    if(confirm("Are you sure you wish to remove this item?"))
    {
        // we use the callback method of the slideUp function
        // so that the removal happens after the animation..
        $(this).parent().slideUp('fast',function(){ $(this).remove(); });
    }
    return false;
});
演示