views:

41

answers:

2

Via SWFobject and AJAX I put in a video to a certain <div>.

Using jQuery I tried this:

$('#youtubepreview').html('');

However that didn't remove it at all - the video still stayed right there.

Any ideas?

+2  A: 

This worked for me:

$("#youtubepreview object").remove();
Magnar
Struggled with it - and then an epiphany. When swfobject applies a video to a certain DIV, it doesn't next it, but turns the actual div INTO the object itself. So I guess I just need a dual-layer system so I can keep at least one DIV intact.
jeffkee
$('#youtubecontainer'+suffix).remove('object'); $('#youtubecontainer'+suffix).html('<div id=\"youtubepreview'+suffix+'\"></div>');// and then re-embed a new video that will replace the old one, or leave it blank if the video is supposed to be blank. Thanks for the pointer towards the remove() function!
jeffkee
+2  A: 

SWFObject also has a removeSWF method you can invoke if needed.

Assuming the SWF was embedded with the ID "mySwfID":

swfobject.removeSWF("mySwfID");
pipwerks