Is it possible to use jQuery detach () or appendTo () with toggle / animate?

$('#step1').eq(1).detach().appendTo('#tmp'); $('#step2').detach().appendTo('.content'); 

I have a div holder class="content" , when I click the button #step1 disconnected and added to the div div #tmp , #step2 is separated from another place and added to <div class="content">

Is there a way to use a detachable combine with animation or switching?

I tried .animate({width:'toggle'},2000) but it does not work.

+4
source share
1 answer

In order to expand the comment on zacechola, you want to animate the element hiding, and then disconnect / attach, then animate showing it again.

So something like:

 var element = ... var newParent = ... element.slideup('normal', function() { element.detach().appendTo(newParent); element.slidedown('normal'); }); 
+1
source

Source: https://habr.com/ru/post/1385415/


All Articles