JQuery.remove () - Is there a way to return an object after deleting it?

I basically have the same problem on these issues:

Flash video still works in hidden div

I used the .remove jquery call and this works. However, I have previous / next buttons when the user scrolls hidden / non-hidden divs. I need to know, as soon as I delete the Flash object, is there a way to return it other than refreshing the page?

Basically, is it possible to handle this on the client side, or will I need to do the processing on the server side.

Disable () will not work because Flash video continues to play.

I can't just hide it because the video continues to play.

+7
jquery
source share
3 answers
$myVariable = $("#removeMe").detach(); 

The .detach() function is explicitly designed to pull something from the DOM in order to return later. It's good.

API Ref: http://api.jquery.com/detach/

+22
source share

You tried:

 var clone = $("#someDiv").clone(true); $("#someDiv").remove(); 
+2
source share

You can assign it to a variable:

 var undo = $('#someDiv') 

Then use the cancel value to reinstall the item.

 $('#placeholder').html(undo) 

You might be better off hiding it rather than deleting it.

+1
source share

All Articles