Tutorial :jQuery.remove() - Is there a way to get the object back after you remove it?



Question:

I basically have the same problem in this questions:

Flash Video still playing in hidden div

I've used the .remove jquery call and this works. However, I have previous/next buttons when a user scrolls through hidden/non-hidden divs. What I need to know is, once I remove the flash object, is there a way to get it back other than refreshing the page?

Basically, can this be handled client side or am I going to need to implement some server side handling.

detach() won't work because the flash video continues to play.

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


Solution:1

$myVariable = $("#removeMe").detach();  

The .detach() function is explicitly made to take something out of the DOM to be put back in later. It's a good'n.

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


Solution:2

Have you tried:

var clone = $("#someDiv").clone(true);  $("#someDiv").remove();  


Solution:3

You can assign it to a variable:

var undo = $('#someDiv')  

Then use the value of "undo" to re-insert the item.

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

Perhaps you're better off hiding it instead of removing it.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »