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

I have a div holder class="content", when click a button, #step1 detached, and append to a temple div #tmp, #step2 detach from some other place and append to <div class="content">

Is there any way to use detach combine with animate or toggle?

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

peipei
  • 1,407
  • 3
  • 14
  • 22
  • 1
    See this question and the top answer. You can put it into a callback function. http://stackoverflow.com/questions/308019/jquery-slideup-remove-doesnt-seem-to-show-the-slideup-animation-before-remo – zacechola Dec 10 '11 at 04:16

1 Answers1

1

To expand on zacechola's comment, you want to animate hiding the item, then detach/append, then animate showing it again.

So something like:

var element = ...
var newParent = ...
element.slideup('normal', function() {
    element.detach().appendTo(newParent);
    element.slidedown('normal');
});
Jason
  • 3,021
  • 1
  • 23
  • 25