Basically I want to wrap some content on my page in a div.
I can do this using the wrap function in jQuery but my issue is that I have a few iframes in my content which contain advertising and when you wrap the content it refreshes the iframes.
From what I can tell this is because behind the scenes it is cloning the content to be wrapped into the new div.
html
<div class="content">
<iframe src="http://something.com/ads"></iframe>
</div>
js
$(content).wrap('awesome_container');
Ideally I would like to just slot in some open div tags before the content div and a few close div tags afterwards but I can't seem to add any divs to the page without it adding close tags.
Does anyone know of a way around this issue?
Cheers
Instead of removing the html or making a copy of it, see if you can get the desired result using jQuery's detach() This will also allow whatever events you have associated with this element and its children to still function afterwards. It may be enough to preserve the iFrame object instead of killing it off.
var orphan = $(selector).detach()
someParent.html(orphan);
Let me know if that helps :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With