Add sliding animation to jquery insertafter and insertbefore

Sowmya picture Sowmya · Jun 10, 2013 · Viewed 14.6k times · Source

How to add animation moving effect to up and down sort movement.

You can check the movement by clicking on the UP and DOWN text links.

Here is my code

$(document).ready(function(){
    $('.move-up').click(function(){
        if ($(this).prev())
            $(this).parent().insertBefore($(this).parent().prev());
    });
    $('.move-down').click(function(){
        if ($(this).next())
            $(this).parent().insertAfter($(this).parent().next());
    });
});

DEMO

Answer

Rodrigo Serzedello picture Rodrigo Serzedello · May 19, 2015

just add the a sequence of hide and show, easy!

jQuery(html_usr).insertBefore( "#log_row" ).hide().show('slow');