Replace the surround of an html element with another document

Posted by KvanteTore on Stack Overflow See other posts from Stack Overflow or by KvanteTore
Published on 2010-04-23T22:39:35Z Indexed on 2010/04/23 22:43 UTC
Read the original article Hit count: 212

Filed under:
|
|

I have an html page with (among other things) a Unity3D window. I would like to replace everything on the page without causing the Unity window to reload. I have tried the following jquery-tastic

   function replaceSurround(keepElem, newElem)
    {
        keepElem.siblings().remove();
        keepElem.prepend(newElem.prevAll());
        keepElem.append(newElem.nextAll());

        var keepParent = keepElem.parent();
        var newParent = newElem.parent();
        if (keepParent && newParent)
        {
            replaceSurround(keepParent, newParent);
        }
    }

where keepElem is an element in the original document and newElem is the corresponding element in the new document, but it did not work very well.

© Stack Overflow or respective owner

Related posts about html

Related posts about JavaScript