Javascript move div to tag end body </body>
javascript
Solution
Plain simple javascript:
document.body.appendChild(document.getElementById('div2'));
To move the node you just use appendChild method.
And the demo http://jsfiddle.net/6GsbB/
Problem
How to move div to before tag end body `</body>`. I'm using openx, I cannot change div content, because the content owned by others. I just put code javascript from openx in order to get banner I put the code after tag `<body>` before anyting tag in content. And my problem is, when I put javascript from openx to generate banner I get two div parallel, which the banner in `<div id="div1">` and `<div id="div2">` there are in below tag `<body>`, I want to `<div id="div1">` after tag start body `<body>` above anyting tag in content. And `<div id="div2">` in before tag end body `</body>` after anyting tag. This is I get html from openx, as below: ``` <!DOCTYPE html> <html> <head> </head> <body> <div id="div1"><img src="blablabla" /></div> <div id="div2"><img src="blablabla" /></div> Here is content other div id or div class, I not define example insert after div id footer Because this is content owned by others. This is justexample content. </body> </html> ``` and I want to transform to as below: ``` <!DOCTYPE html> <html> <head> </head> <body> <div id="div1"><img src="blablabla" /></div> Here is content other div id or div class, I not define, example insert after div id footer Because this is content owned by others. This is justexample content. <div id="div2"><img src="blablabla" /></div> </body> </html> ``` Because I want to put banner one above content and banner two to below content. I don't want to use CSS `position: fixed`. So, possible to move tag div to before tag end body? If possible, please help me code javascript to do it. Thanks.