sass
sass

Reputation: 19

How to return something after removing it with jQuery

I use $(selector).remove(); in jQuery to remove some elements, and want to be able to return those after I deleted them.

How can I return them when they are removed?

My code:

$("#cir1").click(function(){
   $("#cir2").fadeOut(100);
   $("#cir2").remove();
   $("#con2").fadeOut(100);
   $("#cir3").fadeOut(100);
   $("#cir3").remove();
   $("#con3").fadeOut(100);
   $("#cir4").fadeOut(100);
   $("#cir4").remove();
   $("#con4").fadeOut(100);
   $("#cir1").animate({
      width:'590px',
      height:'590px',
      borderRadius:'800px',
      left:'-2px',
      top:'-3.5px',
   });
   $(".matt").fadeOut(100);
   $("#con1").fadeOut(100);
   $("#abcon").fadeIn(300);
});
$("#back").mouseenter(function(){
   $("#cir1").animate({
      width:'195px',
      height:'195px',
      borderRadius:'100px',
   });

   $(".matt").fadeIn(100);
   $("#abcon").fadeOut(300);
   $("#cir2").fadeIn(100);
   $("#cir3").fadeIn(100);    
   $("#cir4").fadeIn(100);  
});

Upvotes: 1

Views: 156

Answers (1)

adeneo
adeneo

Reputation: 318302

You can use jQuery's detach() instead.

var element = $("#cir3").detach();

// stuff

element.appendTo('#something');

Upvotes: 3

Related Questions