Solved

jQuery: put body inside container div

Posted on 2011-09-28
2
304 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to dynamically set the form action using jQuery.
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…

733 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