move entire body into div

P

Petra Meier

hello,

I want to display an element underneath (zindex) the entire body.
so I want to move the entire dom from the body node into an absolute
div (top/left 0/0) , then create a new div with that element with
lower zindex and place it under the "body" div.

how do I best do that?
 
R

RobG

hello,

I want to display an element underneath (zindex) the entire body.
so I want to move the entire dom from the body node into an absolute
div (top/left 0/0) , then create a new div with that element with
lower zindex and place it under the "body" div.

how do I best do that?

Get a reference to the body element, create your new div, loop over
all the child nodes of the body and attach them to the div, attach the
div to the body. Something like:

var body = document.body;
var div = document.createElement('div');
while (body.firstChild) {
div.appendChild(body.firstChild);
}
body.appendChild(div);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,089
Messages
2,570,602
Members
47,223
Latest member
smithjens316

Latest Threads

Top