Solved

jQuery: put body inside container div

Posted on 2011-09-28
2
293 Views
Last Modified: 2012-06-27
Using jQuery, I want to put everything inside the body inside a container div.

This:
<body>
<div>
<h1>Hello</h1>
<p>World</p>
</div>
</body>

Open in new window


Should become this:

<body>
<div id="container">
<div>
<h1>Hello</h1>
<p>World</p>
</div>
</div>
</body>

Open in new window

0
Comment
Question by:hankknight
2 Comments
 
LVL 11

Accepted Solution

by:
MacAnthony earned 400 total points
ID: 36719375
Take a look at wrapInner.

$('body').wrapInner('<div id="container" />');
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 100 total points
ID: 36720316
Test page : http://jsfiddle.net/UtebB/
var $b = $("body").children();
var $d = $("<div id='container' />").append($b);
$d.appendTo("body");

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now