Problems with slideDown in jQuery

2

I have a problem that I do not have the slightest idea of what can be, I understand little of jQuery, in the remove I was able to do the animation of .slideUp() but in add that it is a .append() I can not make it work already I tried several forms and will not, follow below the link with the codes.

link

    
asked by anonymous 19.08.2014 / 01:29

1 answer

3

The new element should come hidden to the slideDown being able to show it, add display:none online or in the class of the new element:

$(document).ready(function(){
    //when the Add Filed button is clicked
    $(".adicionarCampo").click(function () {
        //Append a new row of code to the "#items" div
        $(".lista").append('<div class="nomes" style="display:none"><input class="input-adicional" id="nome" name="nome[]" placeholder="Nome completo" type="text" /><a href="javascript:void(0)" class="delete"></a></div>');
        $(".nomes").slideDown("slow");
        $("body").animate({scrollTop: $("body").prop("scrollHeight")}, 500);
    });

    $("body").on("click", ".delete", function () {
        $(this).parent("div").slideUp("fast", function() {
            $(this).remove()    
        })
    });
});
    
19.08.2014 / 01:34