Re: Putting DIV wrapper around all code in body
- From: Alexey Kulentsov <akul@xxxxxxxx>
- Date: Sun, 30 Mar 2008 19:58:41 +0000
andrej.kaurin@xxxxxxxxx wrote:
Initial DOM....
<body>
<div>
<p>Some text</p>
Modified DOM with javascript....
<body>
<div id="myWrapper">
<div>
Any idea?
HTML
<head>
<script>
function addDiv()
{
// get body tag
var body=document.getElementsByTagName('body').item(0);
// create div element
var div=document.createElement('div');
// demonstrate it
// set id here if you want
div.style.border='1px solid red';
div.style.padding='0 1ex';
// while here is child in body..
var e;
while(e=body.firstChild)
// move it to div
div.appendChild(e);
// append div to body
body.appendChild(div);
}
</script>
</head>
<body onload="addDiv()">
<div>
<p>Some text</p>
<p>More text</p>
</div>
</body>
/HTML
.
- Follow-Ups:
- Re: Putting DIV wrapper around all code in body
- From: George Maicovschi
- Re: Putting DIV wrapper around all code in body
- References:
- Putting DIV wrapper around all code in body
- From: andrej . kaurin
- Putting DIV wrapper around all code in body
- Prev by Date: Re: Other scripting languages?
- Next by Date: getElementByName within containing DIV
- Previous by thread: Putting DIV wrapper around all code in body
- Next by thread: Re: Putting DIV wrapper around all code in body
- Index(es):
Relevant Pages
|