[Javascript] .appendParent
David Dorward
david at dorward.me.uk
Tue Nov 18 08:52:56 CST 2008
Terry Riegel wrote:
> <div id="main">
> blah...
> </div>
> Is there a way to appendParent to get something like
>
> <div id="appendage">
> <div id="main">
> blah...
> </div>
> </div>
Insert the wrapper before the existing content, then move the existing
content inside it.
var main = document.createElementById('main');
var appendage = document.createElement('div');
main.parentNode.insertBefore(appendage, main);
appendage.appendChild(main);
--
David Dorward <http://dorward.me.uk/>
More information about the Javascript
mailing list