开发者

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

I basically have the same pr开发者_开发知识库oblem 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.


$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/


Have you tried:

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜